Hello. I have two tables "Employees" with two fields "Name" and "Badge Number". The second table "Checkout" has multiple fields and the first two are "EmployeeName" and "EmployeeNumber". I made the first one "EmployeeName" a lookup field from the table "Employee" and The second field "EmployeeNumber" as a number "not a lookup".
I created a form based on the "Checkout" table which atutomatically created a combox for the EmployeeName field since it is a lookup field.
I created a textbox field on the form to diplay the badge number and then store its content in the Badgenumber field of checkout table. My question is this. I want the textbox that displays the badge number on the form gets popluated automatically once I choose the employee from the combo box above it. I tried using DLOOKUP function but i did not work. can someone help me with this. Also, since my form is based on the checkout table, will the badgenumber field on the form send the data to the cooresponding field in the table "checkout" automatically. Sorry..i know this is a basic question but i just started working with access.
No apologies needed for basic questions. They are the most important.
First an off topic note. Try to use some naming conventions for your tables and other objects (i.e.: tblCheckout instead of Checkout). It helps in figuring out what wort of object is being referred to.
Now back on topic: Open the form in design view, right click on the combo box and you will get a Properties dialogue box. Click on the Data tab and then go to Row Source. Open up the row source (you will end up with a query in design view). Make sure that your query contains the Badge NUmber field from the Employee table. And to prevent confusion, make sure it is the 2nd field in the query.
Close the query, go back to the Properties box and click on the Event's tab. There will be an event for After Update (this isn't the only event that might work for your purpose). Click on the little button (with the down pointer) near the right side of the After Update line and add [Event Procedure]. Then click on the adjacent button (with three little dots) and open up the VBA code screen. What you see should look like: