DLookup syntax error- can't figure out what I am doing wrong.

Need_Excelhelp

New Member
Joined
Oct 14, 2014
Messages
22
Hi,

I am a complete newbie at Access. Through google, I learned that DLookup is the access version of Vlookup.

I tried the following function in various ways and am getting syntax- (missing operator) in query expression '[begDate]=9/28/...' error.

1. net: DLookUp("[ccFee]","ccFee","[begDate] =" & [timestamp])
2. net: DLookUp("[ccFee]","ccFee","[begDate] ='" & [timestamp]&"'")
3. net: DLookUp("[ccFee]","ccFee","[begDate] =" & Chr(34) & [timestamp] & Chr(34))

In the first option, I am doing exactly the same as this YT tutorial.

However, I have no idea what I am doing wrong and why I am getting the same errors. I also tried by adding and deleting spaces between characters.

Is there any other way to do a "Vlookup" in Access?

I would appreciate all your help. Thank you so much in advance.

Regards,

N_EH
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Why are your first and second arguments the same value ("ccFee")?
The first argument is the name of the FIELD you want to return.
The second argument is the name of the TABLE/QUERY that field is found in.
I think you want the third argument to look something like this:
Code:
[COLOR=#333333]"[begDate] =#" & [timestamp] & "#"[/COLOR]

See here for more help on DLOOKUP: MS Access: DLookup Function
 
Upvote 0
Thank you for your prompt reply.

I have a table that's called ccFee and in that table, there are two fields, begDate and ccFee. What I want to do is look at the timestamp in my current query, and match it with the begDate in ccFee Table to get the correct ccFee attributed to this field.

I will try your suggestion in argument 3 and look at the link you provided and let you know how it goes.

Once again, thank you so much for your help!
 
Upvote 0
I would also recommend that you try to avoid having field names the exact same name as table names. It could cause confusion.
 
Upvote 0
Why are your first and second arguments the same value ("ccFee")?
The first argument is the name of the FIELD you want to return.
The second argument is the name of the TABLE/QUERY that field is found in.
I think you want the third argument to look something like this:
Code:
[COLOR=#333333]"[begDate] =#" & [timestamp] & "#"[/COLOR]


See here for more help on DLOOKUP: MS Access: DLookup Function

So, I was using the string format instead of date. It seems to have removed the error, but now when I run the query, everything is blank in net column.

Edit: Just changed the ccFee field to ccFees--and made appropriate change in the current query. Do you know why might the cells in net column be blank?
 
Last edited:
Upvote 0
Are your begdate and timestamp fields both Date fields and not Text fields?

You might need to do something like:
Code:
[COLOR=#333333]"[begDate] =#" & Format([timestamp],"mm/dd/yyyy") & "#"[/COLOR]
 
Upvote 0
Are your begdate and timestamp fields both Date fields and not Text fields?

You might need to do something like:
Code:
[COLOR=#333333]"[begDate] =#" & Format([timestamp],"mm/dd/yyyy") & "#"[/COLOR]

No, they both are in the same "mm/dd/yyyy" format.
 
Last edited:
Upvote 0
If they are both in date format, the structure like in post #2 should work.
It is difficult to know exactly what the issue may be without setting your data tables.
Are you sure that neither date field has a time piece to it?
 
Upvote 0
If they are both in date format, the structure like in post #2 should work.
It is difficult to know exactly what the issue may be without setting your data tables.
Are you sure that neither date field has a time piece to it?


Originally, they both have time attached to it. I have formated the begDate field in ccFee table to mm/dd/yyyy and have added format() of mm/dd/yyyy around timestamp like you mentioned in the previous reply.

This is the expression I have right now:
DLookUp("[ccFees]","ccFee","[begDate]=#" & Format([timestamp],"mm/dd/yyyy") & "#")

p.s. Is there any way I can send the two tables on this website so you could have a look?
 
Last edited:
Upvote 0
Changing the FORMAT property on the field itself does not remove/eliminate the time component of that field. It just "hides" it from view. But it is still there, so the values will not be equal. The FORMAT function converts the value to Text, so then it would work, but you would have to apply it to both fields so you get a Text-to-Text comparison.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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