Need help with a Combo box value lookup

padesbiens

New member
Local time
Today, 09:50
Joined
Mar 14, 2012
Messages
3
I am a new Access user and need assistance with a combo box on a form. Combo box "cbCountryName" allows the user to choose a country (with the control source from table "tblCountry"). When a specific country is chosen, I want the associated foreign exchange rate "CurrentFXRate" which is also stored in tblCountry to be displayed in a textbox below. I have been trying SetTempVar but haven't had any luck...Can anyone help? Thanks!
 
For just one entry, i would suggest using a Dlookup as the default value of the textbox.

Then refresh the textbox in the afterupdate event of the dropdown box.

DLookup("CurrentFXRate", "tblCountry", "cbCountryName = " & Forms![yourform]!yourlistbox)

This will give an error if your default value of the dropdown is blank. The other way would be to set the value of the txtbox to the same dlookup on the afterupdate event of the dropdown.

Forms![yourform]!yourtxtbox =
DLookup("CurrentFXRate", "tblCountry", "cbCountryName = " & Forms![yourform]!yourlistbox)

Change the green text into the appropriate names.
 
Last edited:
This is great, thanks!!
 

Users who are viewing this thread

Back
Top Bottom