Dlookup - probably a basic question

ferijen

New Member
Joined
Nov 16, 2004
Messages
12
Hi there

I'm much happier in Excel but have found myself building an Access database. I would like a Form (inputdata) to feed into the table (Maindataset).

Within the form (which will be for non specialist users) I would like a user to select a country from a drop down box. There is another table called 'country & region' and I would like the country selected from the drop down box to auto fill the field on the form (and table) with the associated region. So, user selects UK, region is Europe, user selects Hong Kong, region is China etc.

I'm almost there... I think... but its only returning 'China' as region no matter what country is selected. China is top of the 'country & region' table.

My code is

=DLookUp("[Country]","[Country & region]","'[Country]=[Country]'")

(where the first and last 'Country' comes from the 'Country & region' lookup table... I'm guessing that this ought to have a different name to the 'Country' which goes into the main table, but even when I've changed the names, its not helped)

(changing the code again if I changed the field names, it would be
=DLookUp("[Countrylookup]","[Country & region]","'[Country]=[Countrylookup]'") )

Can anyone help? I'm in access 2003 if it makes a difference.
 
I'm not sure how 03 works, but you may need to but an embedded macro on the dropdown to do something like requery after update.
 
Last edited:
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Since my last message, a colleague has come in who knows nothing about DLookup but has set me up with multiple combo boxes, so it does what it needs to do...

Thank you (sorry I couldn't get the Dlookup working though!)
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top