[AccessD] Setting focus to a field on a subform

Mcgillivray, Donald [ITS] donald.a.Mcgillivray at mail.sprint.com
Thu Aug 7 14:01:12 CDT 2003


John,

How about using the BeforeUpdate event of the subform itself instead of
the OnExit of the subform control on the main form?  Then you can cancel
the update and reposition the cursor as you wish.

Also, you may eliminate the 'X=' before your Msgbox if you eliminate the
parentheses surrounding the Msgbox arguments.

HTH
Don McGillivray

-----Original Message-----
From: John Clark [mailto:John.Clark at niagaracounty.com] 
Sent: Thursday, August 07, 2003 11:42 AM
To: accessd at databaseadvisors.com
Subject: [AccessD] Setting focus to a field on a subform


On a subform, I have four 'funding source' fields. Before the user
leaves this subform, I want to ensure that they have chosen at least one
of these. If none of these are chosen, then I want to present a message
box and bounce back to the subform...preferably to the first of the fund
sources. I put the following code into the 'On Exit' event of the
subform control:

If (chkCSE = False) And (chkCSI = False) And (chk3B = False) And (chk3E
= False) Then
	X = MsgBox("You have no funding source selected.", vbOKOnly,
"Funding Source Error")
    	Me!sfrmSubConts.SetFocus
    	'Me!sfrmSubConts.Form!chkCSE.SetFocus
End If


As you may notice, I have commented out the last line...it didn't work
on its own, and I also tried it along w/the previous line. 

Also, I haven't used message boxes too much, but I didn't think I needed
the 'X =' that I apparently needed to include. 

Thanks 

John W Clark
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list