[AccessD] Setting focus to a field on a subform

John Clark John.Clark at niagaracounty.com
Thu Aug 7 13:41:42 CDT 2003


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


More information about the AccessD mailing list