Set Focus

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
 
J

Jeff Boyce

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>
 
G

Gerald Stanley

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
 
T

Tony Williams

Thanks Gerald that seems to be what I'm going to do, others have commented
on my mistake here
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top