If you place the code in the LostFocus event of the
FORM, the the control name would need to be the fully qualified format (Form!form("
formname"

.
ControlName, or something similar (I often get the specifics of these constructions worng the first time or several!). A "better location would be in the LostFocus event of the control, but then, you would need to be sure that the form would have the location before there was any poossability that this control could have the focus to begin with.
The "syntax" of your sub inidcates that "stepnp" is, however, the control name. Further, I would suggest that you simply use the SetFocus Method, rather than the DoCmd....
I copied your procedure, modified it to reflect a control on an existing form in one of my plethora of 'sample' databases, and it appears to work, as shown by the following (note the Debug.Print statements). Unfortunatly, the reality seems to NOT actuall move the cursor back to the control, which I'm not at all understanding. I KNOW I've done this a several multituds of times before w/o these problems.
Code:
Private Sub txtComment_LostFocus()
Debug.Print "Start: " & Me.ActiveControl.Name
If IsNull(Me("txtComment")) Then
MsgBox "You must scan the route step"
Me("txtComment").SetFocus
End If
Debug.Print "End: " & Me.ActiveControl.Name
End Sub
MichaelRed
m.red@att.net
Searching for employment in all the wrong places