handsomed
Nov 19 2008, 10:52 AM
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?
theDBguy
Nov 19 2008, 11:07 AM
Can you show us the code you're using?
handsomed
Nov 19 2008, 11:13 AM
If IsNull(NAME) Then
MsgBox "You must write your name"
NAME.SetFocus
.......
theDBguy
Nov 19 2008, 11:37 AM
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?
handsomed
Nov 19 2008, 12:25 PM
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
theDBguy
Nov 19 2008, 12:34 PM
Try this...
If IsNull(FIRSTNAME) Then
MsgBox "You must write your name"
Screen.PreviousControl.SetFocus
(untested)
Hope that helps...
handsomed
Nov 19 2008, 12:44 PM
I didn't work theDBguy
theDBguy
Nov 19 2008, 01:12 PM
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...
handsomed
Nov 19 2008, 01:35 PM
It worked theDBguy!
Curious way!
Thanks everyone
theDBguy
Nov 19 2008, 01:53 PM
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.