0
votes

I'm fairly new to Access, but have most of the basics down because I've used Excel for years. I'm trying to do a DLookup on a table. It's a really large table.

My DLookup is returning blank. It's not giving me an error message or returning "null." It's just blank. I'm searching a text field to return a numerical value. I'm using this below:

Results: DLookUp("[Meas]","[Database]","[Description]='" & [Description] & "'")

The table looks similiar to below:

Description                 Weight(g)    Measure                        Protein(g)Per Measure       Cholesterol(mg)Per Measure
Butter, salted              5            1.0 pat (1" sq, 1/3" high)     0.04                        11
Butter, whipped, with salt  3.8          1.0 pat (1" sq, 1/3" high)     0.03                        8
Butter oil, anhydrous       12.8         1.0 tbsp                       0.04                        33
Cheese, blue                28.35        1.0 oz                         6.07                        21
Cheese, brick               132          1.0 cup, diced                 30.68                       124
Cheese, brie                28.35        1.0 oz                         5.88                        28

Any idea what could be causing this? Or do I need to try to put this in VBA?

1
please explain better the problem and post more code - faby
That's the only code I'm using. It's worked for all the other tables, but not this one. I'm thinking it may be the way it is formatted. It should look up the Description column and return what's in another column...say the Protein column. - user3673931
Where is the value Description coming from and what does it contain? - Andy G
BTW Database is not a sensible name for a table. - Andy G
And for the same reason, Description is a bad name for a field. - david

1 Answers

0
votes

From the example code you provided, the only issue I'm seeing is that there's a column called Measure in the table, but you are selecting Meas in your DLookup.

Another thing you could try is: creating a new query in Access, switch to SQL View, paste the following SQL and try to execute the query:

select [Meas] from [Database] where [Description]='whatever'"

(this is the SQL equivalent to your DLookup statement)

Does it run without errors?
If yes, does it return any rows?


If neither of this does help, you need to provide more information.

For a start, I'd like to see the exact column names and the exact DLookup statement.
I'm not sure whether you gave us the real data, because you said "The table looks similiar to below". Similar is not enough here!