AboutRichard Rost Expertise I am happy to answer any kinds of questions about Microsoft Access - from basic table design to advanced VBA programming. Also, please feel free to check the Access Tips & Tricks section of my web site.
Education/Credentials I am a self-taught Access expert. I have been building databases for clients since the early 90s. You can see a sample of my Access Tutorials on my web site at 599CD.com
Question QUESTION: I have a subform with the emplid as the first feild. when they tab it does the Dlookup. If it can't find the first name it sets the value of emplid to spaces. I want it to go back to the emplid so they can start over. Right now it goes to the feild i tabbed to.
Private Sub EMPLID_AfterUpdate()
EMPLID.SetFocus
If IsNull(DLookup("[FNAME]", "candidates", "emplid = LMPeople")) Then
MsgBox "No records were found. Please try again."
LMPeople = " "
P.P.S. I volunteer my time at AllExperts to help people, and I get a LOT of questions, so I can't take an hour to answer each question. If you need more DETAILED HELP, come to my TechHelp web site at http://www.599cd.com/TechHelp/AllExperts and I'll take as much time as you need to answer your question.
QUESTION: I tried DoCmd.GoToControl "LMPeople" it doesn't appear to work The field is named LMPeople on the subform. In the field preferences the control is LMPeople, but I get an error runtime 2109 stating that LMPeople is not a field in the current record. In the Dlookup I am using that field name to find my value.
Answer If you want to refer to a value on a Form, you can use the notation:
Forms!FormName!FieldName
You can use this notation inside of queries, other forms, or even reports. I have a free tutorial that explains how to use this:
P.P.S. I volunteer my time at AllExperts to help people, and I get a LOT of questions, so I can't take an hour to answer each question. If you need more DETAILED HELP, come to my TechHelp web site at http://www.599cd.com/TechHelp/AllExperts and I'll take as much time as you need to answer your question.