By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,705 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,705 IT Pros & Developers. It's quick & easy.

Probably a simple question....

P: n/a
I've gotten this far:

When a field is left blank, I have a message box popping up that says
"You must enter a name." This is the code that used:

Private Sub Entered_By_Exit(Cancel As Integer)
If IsNull(Me![Entered by]) Then MsgBox "You must enter a name"
End Sub

Now the only addition I want to do that I can't figure out is is that
I want the cursor to return to that field that created the message
box. As it is now, the cursor moved on to the next field.

Thanks!
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 23 Feb 2004 12:22:53 -0800, mh********@yahoo.com (MatGyver) wrote:

Re-read the help page on the Exit event. It will say something about
the Cancel argument: if you set it to True, the user won't be able to
leave the field.

BTW, I prefer such checks in the Form_BeforeUpdate event. What if the
user is very mouse-centric and never entered the [Entered by] field?
Your code would not fire; mine would.

BTW2: Entered by can typically be a hidden field, programmatically set
to the name of the logged in user. See
http://www.mvps.org/access/api/api0008.htm for details.

-Tom.

I've gotten this far:

When a field is left blank, I have a message box popping up that says
"You must enter a name." This is the code that used:

Private Sub Entered_By_Exit(Cancel As Integer)
If IsNull(Me![Entered by]) Then MsgBox "You must enter a name"
End Sub

Now the only addition I want to do that I can't figure out is is that
I want the cursor to return to that field that created the message
box. As it is now, the cursor moved on to the next field.

Thanks!


Nov 12 '05 #2

P: n/a
Tom,

You can also use the SetFocus property to move the cursor back to the field
in question.

Regards

Richard Walters

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:et********************************@4ax.com...
On 23 Feb 2004 12:22:53 -0800, mh********@yahoo.com (MatGyver) wrote:

Re-read the help page on the Exit event. It will say something about
the Cancel argument: if you set it to True, the user won't be able to
leave the field.

BTW, I prefer such checks in the Form_BeforeUpdate event. What if the
user is very mouse-centric and never entered the [Entered by] field?
Your code would not fire; mine would.

BTW2: Entered by can typically be a hidden field, programmatically set
to the name of the logged in user. See
http://www.mvps.org/access/api/api0008.htm for details.

-Tom.

I've gotten this far:

When a field is left blank, I have a message box popping up that says
"You must enter a name." This is the code that used:

Private Sub Entered_By_Exit(Cancel As Integer)
If IsNull(Me![Entered by]) Then MsgBox "You must enter a name"
End Sub

Now the only addition I want to do that I can't figure out is is that
I want the cursor to return to that field that created the message
box. As it is now, the cursor moved on to the next field.

Thanks!

Nov 12 '05 #3

P: n/a
On Mon, 23 Feb 2004 21:19:40 -0000, "Richard Walters"
<ri*****@walters225nospam.freeserve.co.uk> wrote:

Perhaps. Although that doesn't work in the comparable LostFocus event.
I consider:
Cancel = True
a lot better than:
SomeControl.SetFocus
because it uses the infrastructure already provided by Access, and is
therefore likely more bulletproof. For example in cases where focus is
lost to another (popup) form.

-Tom.

Tom,

You can also use the SetFocus property to move the cursor back to the field
in question.

Regards

Richard Walters

"Tom van Stiphout" <to*****@no.spam.cox.net> wrote in message
news:et********************************@4ax.com.. .
On 23 Feb 2004 12:22:53 -0800, mh********@yahoo.com (MatGyver) wrote:

Re-read the help page on the Exit event. It will say something about
the Cancel argument: if you set it to True, the user won't be able to
leave the field.

BTW, I prefer such checks in the Form_BeforeUpdate event. What if the
user is very mouse-centric and never entered the [Entered by] field?
Your code would not fire; mine would.

BTW2: Entered by can typically be a hidden field, programmatically set
to the name of the logged in user. See
http://www.mvps.org/access/api/api0008.htm for details.

-Tom.

>I've gotten this far:
>
>When a field is left blank, I have a message box popping up that says
>"You must enter a name." This is the code that used:
>
>Private Sub Entered_By_Exit(Cancel As Integer)
> If IsNull(Me![Entered by]) Then MsgBox "You must enter a name"
>End Sub
>
>Now the only addition I want to do that I can't figure out is is that
>I want the cursor to return to that field that created the message
>box. As it is now, the cursor moved on to the next field.
>
>Thanks!


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.