I'm working with a form that has a number of required fields that must be filled out. In order to guarantee they're completed, I'm using an OnUnload script as follows (ElseIf variations removed for brevity):
If Not mcblnDeleted Then
If (Nz(Species, "") = "" Or Nz(Common_Name, "") = "" Or Nz(Group, "") = "" Or Nz(Family, "") = "" Or Nz(WBRCGroup, "") = "") Then
If Nz(Species, "") = "" Then
MsgBox "You must fill out the species before closing the record.", vbOKOnly, gcstrMSGBOX_DEFAULT_TITLE
Forms!frmSpecies!Species.SetFocus
(Other cases)
End If
Cancel = True
End If
End If
The idea being that if a required field is missing, it will pop up the appropriate error and set focus to the field in question.
The problem is that SetFocus doesn't seem to be working, because by clicking to close the form on the window listing... it puts the focus up there, and thus although the required field is highlighted, you still need to click on it to enter information.
I tried putting a SetFocus event for the form itself before narrowing into the required field, but it had no effect. GotoControl seems like it would be even less useful in this instance.