Newbie form question: combo box populated by one table, but writes to another

natesternberg

Registered User.
Local time
Today, 05:26
Joined
Mar 3, 2011
Messages
11
Ok, I have a simple question. I have a database containing volunteers and the hours they worked. There's two tables:

tblVolunteers:
ID AutoNumber
FName Text
LName Text


tblHours:
workID AutoNumber
workerID Number (foreign key)
StartTime Date/Time
EndTime Date/Time


I want a datagrid-like form where the user inputs start and end time, and selects the volunteer's name from a drop-down (populated from tblVolunteers). Then, when the user completes the row, it looks up the corresponding ID from tblVolunteers and puts it in tblHours.workerID.

Now, I can make a drop-down that gets populated from tblVolunteers (by setting its "Row Source" to a query). What I don't know how to do is perform the appropriate lookup to fill in tblHours.workerID. This is probably easy to do, but this is my first database.

(I'm familiar with VBA and T-SQL, by the way; just not sure how to set up the form).

Any suggestions?
 
Welcome to the forum

Have a look at the sample posted here.

Wow, that was fast. Thanks!

It took me a sec to figure out how your example works, but I think I get it now. I've applied the idea to my database, and it now works!

Just to summarize:
1) Set the combo's "control source" to be the workerID column in the tblVolunteer table
2) Make sure the ID column gets pulled in within the "row source" query
3) Set the combo's "bound column" to be the one containing the ID. Voila!

Thanks again!
 

Users who are viewing this thread

Back
Top Bottom