Populating text box with 2 combo boxes

kdirvin

Registered User.
Local time
Today, 06:28
Joined
Feb 13, 2011
Messages
41
Hi all,
I have a table, tbl_Account Years, which stores annual financial data for several bank accounts. I have a primary key ID field (AutoNumber), an Account Number field, a Year field, and an Amount field. This allows the user to store what each account had for each year.
I want a form that allows me to select the year and the account number from two separate combo boxes. These selections would then automatically populate a text box with the corresponding amount from the Amount field. I tried the “have my combo find a particular record” option in the Account Number combo wizard, but the Amount textbox would always populate from one particular year, and not necessarily the one selected.
I then tried setting up the Account Number combo with the Amount field as a hidden column, then coding the Amount text box to pull from that column. That failed to populate the text box with any data.
What tack should I try at this point?
Thank you always!
 
You can either open a recordset or use a DLookup once both combos are populated:

http://www.mvps.org/access/general/gen0018.htm

You can try having the control source of the textbox as the DLookup, though I'm not sure how it will react to empty combos. Personally I'd probably have code in the after update event of both combos to test their contents and set the textbox appropriately.
 

Users who are viewing this thread

Back
Top Bottom