My Assistant
![]() ![]() |
|
|
Nov 19 2008, 10:52 AM
Post
#1
|
|
|
UtterAccess Veteran Posts: 394 |
I'd like to force the user to fill a column, so I have in the event "when lose the focus" the code to show a messagebox and the setfocus property to the column but it doesn't work. It shows the message but the focus is set to the column which a pointed to.
Any ideas? |
|
|
|
Nov 19 2008, 11:07 AM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 48,594 From: SoCal, USA |
Can you show us the code you're using?
|
|
|
|
Nov 19 2008, 11:13 AM
Post
#3
|
|
|
UtterAccess Veteran Posts: 394 |
If IsNull(NAME) Then
MsgBox "You must write your name" NAME.SetFocus ....... |
|
|
|
Nov 19 2008, 11:37 AM
Post
#4
|
|
|
Access Wiki and Forums Moderator Posts: 48,594 From: SoCal, USA |
Just curious... "NAME" is a reserved word in Access. Using it for field or control names can cause unexpected results. Could you try changing those names into something else, for example "FirstName", and see if that helps?
|
|
|
|
Nov 19 2008, 12:25 PM
Post
#5
|
|
|
UtterAccess Veteran Posts: 394 |
Sorry, it was an example, I wrote NAME but I don't use it, my code would be:
If IsNull(FIRSTNAME) Then MsgBox "You must write your name" FIRSTNAME.SetFocus Then when I click to another control, i get de message but not the focus to FIRSTNAME |
|
|
|
Nov 19 2008, 12:34 PM
Post
#6
|
|
|
Access Wiki and Forums Moderator Posts: 48,594 From: SoCal, USA |
Try this...
If IsNull(FIRSTNAME) Then MsgBox "You must write your name" Screen.PreviousControl.SetFocus (untested) Hope that helps... |
|
|
|
Nov 19 2008, 12:44 PM
Post
#7
|
|
|
UtterAccess Veteran Posts: 394 |
I didn't work theDBguy
|
|
|
|
Nov 19 2008, 01:12 PM
Post
#8
|
|
|
Access Wiki and Forums Moderator Posts: 48,594 From: SoCal, USA |
Sorry about that, you might have to move the focus around a bit first to see if it helps...
If IsNull(FIRSTNAME) Then MsgBox "You must write your name" Me.SomeOtherControl.SetFocus Me.FIRSTNAME.SetFocus (untested) Hope that helps... |
|
|
|
Nov 19 2008, 01:35 PM
Post
#9
|
|
|
UtterAccess Veteran Posts: 394 |
It worked theDBguy!
Curious way! Thanks everyone |
|
|
|
Nov 19 2008, 01:53 PM
Post
#10
|
|
|
Access Wiki and Forums Moderator Posts: 48,594 From: SoCal, USA |
You're welcome. Glad we could help. Good luck with your project.
Note: If you are curious, it has to do with where the focus is at the moment the lost focus event fires. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th June 2013 - 07:41 PM |