Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

having a form autofill information from a table

Status
Not open for further replies.

rudeboyjeff

IS-IT--Management
Jun 18, 2002
37
US
Here is my dilemma ladies and gentlemen... I am putting some finishing touches on a work order request system at my place of employment, and I can't figure out how to do this: I have a table called users table. It has 3 colums: Login Name, First Name, and Last Name. In the main database, I also have these three columns. What i need to do is on a form, when someone would type in their login name, their first and last name get automatically filled. Is what i'm asking Access to do possible, or am I just running in circles? I set a one to many relationship from the users table to the main database table.
 
I am going to call your text boxes on the form txtLoginName, txtFirstName and txtLastName. In the control source for txtFirstName, you should use "DLookUp("First Name","Users", [Login Name] = txtLoginName). Similarly in the control source for txtLastName, use "DLookUp("Last Name", "Users", [Login Name] = txtLoginName). In the After Update event of your txtLoginName on the form, use the code
DoCmd.Requery "txtFirstName"
DoCmd.Requery "txtLastName"

and it should update the form with the First and Last name if the Login Name is in the User table.
Kelly
 
Once again I've run into a minor problem. I entered it just like you said, and when i goto form view, it says #Name? in the first and last name spots. Also, the text in txtFirstName and txtLastName have the code that you just gave me. Is this correct, or am I still doing something wrong?

Thanks,
Jeff
 
Jeff,
You probably need to include the explicit reference to the text boxes.
DLookUp("First Name","Users", [Login Name] = Forms!frmMain!txtLoginName)
Let us know what happens. Kelly
 
Hi Kelly,
Once again I have tried to do this, with no luck at all. Would I be able to send you a database with just the pertinent things so you can see where I'm making my mistakes? Both things you mentioned above still give me #Name? and when I try to type something in them, it tells me cannot change; is locked to control source DLookUp("First Name","Users", [Login Name] = Forms!frmHardware!txtLoginName)
 
Sure Jeff, send it on over. I'll take a look at it during my downtime, ASAP.
koehlerk@schneider.com
Kelly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top