Set Focus

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

Can anyone tell me what's wrong with this code? I want it to return to
Docnametxt if user doesn't fill in data but it doesn't do that.
Private Sub DocNametxt_Exit(Cancel As Integer)
If IsNull(DocNametxt.Value) Then
MsgBox ("You cannot save a record without a Document Name"), vbExclamamtion
DocNametxt.SetFocus
End If
If Me.NewRecord Then
Populate_URN
End If
End Sub
 
Tony

One possibility might be to use the control's BeforeUpdate event. Another
is to use your existing code's "Cancel".

Good luck

Jeff Boyce
<Access MVP>
 
You should use Cancel = True not DocNametxt.SetFocus. The
way to look at it is that Access is midway through one
change of focus and cannot be rerouted (even back to the
originator as in your case) but the change can be cancelled.

Hope This Helps
Gerald Stanley MCSD
 
Thanks Gerald that seems to be what I'm going to do, others have commented
on my mistake here
Tony
 
Back
Top