Full Version: Set Focus on a Field
UtterAccess Forums > Microsoft® Access > Access Forms
brownboy
Hi there,
I am having troubles with prompting a user to enter data in a date field prior to entering data in the ID field. I wan the user to fill in the date prior to filling in the ID field. Is there a way that I can bring up a message box telling the user to fill in the date field, when they try to fill in the ID field?...I tried fooling aroudn with the Enter and Got focus properties but am having some difficulties
Any suggestions will be much appreciated
Thanks
StarsFan
Hey Brownboy,
You could put something like this in the Enter or Got Focus property of the ID control.
If Trim(Nz(Me.NameOfDateControl,"")) = "" Then
'Do you message box here
Me.ID.SetFocus
End If
HTH,
Shane
brownboy
Thanks for the help Shane,
o you know how you can do a Message box?
kapeller
Hi !!!!
Have a look at the attached. It may help.
Cheers!!!!!
Lou
brownboy
Hey Shane,
That didnt work. Isnt there a way to check if the date field is empty, then the complaint field cannot accept any entries. Would it go in the Before Update?
Thanks
brownboy
Thanks Lou,
o you have this in Access 97, thats the version I am working on.
Appreciate the help
StarsFan
The code I gave you should be checking if the control is either empty or null. Can you post your code and let us take a look at it?
StarsFan
This is a quick example. Post back if you need more of a kick start than this.
sgBox "You need to fill in Date first", vbOKOnly, "Required Data"
HTH,
Shane
brownboy
Here is the code that I have in the Got focus and Enter field of the ID field.
If Trim(Nz(Me.Date, "")) = "" Then
'Do you message box here
Me.Date.SetFocus
So if the date feild is empty then it should set focus on the date field
brownboy
Nevermind Shane, I got it to work I was referencing the wrong fields lol my mistake. Thanks for your help, it was much appreciated.
StarsFan
Ok, first thing you need to do is rename your Date field. Date is a reserved word in Access.
opy this and put it in the GotFocus event of the ID control and let's see what happens. Be sure to change 'Me.Date' to whatever you rename your date field to.
If Trim(Nz(Me.Date, "")) = "" Then
MsgBox "You need to fill in Date first", vbOKOnly, "Required Data"
Me.Date.SetFocus
End If
Shane
StarsFan
Glad to help.
kapeller
Hi
Sorry about that. Attached is a 97 version.
Cheers!!!!
Lou
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.