Functions with Dlookup?

  • Thread starter Thread starter scadav
  • Start date Start date
S

scadav

Can you use a function within Dlookup? If so, how....

I am trying to extract information from a table, but I want to do it for a
particular month. So I was trying to do the following, but wasn't having
much luck trying to retrieve the month number from a date field. Any help
would be appreciated:

In this example, Date is a Field in the database with the datatype of
Date/Time

sTest = DLookup("[MilesRecordedID]", "VanMiles", "Month([Date]) = " &
iMonth & " AND [VanID] = " & rsVans!VanID)
 
That should work. You sure iMonth is the correct value? Is VanID a text
field? (If so, you need quotes around the value).

BTW, Date is a bad choice for a field name: it's a reserved word, and using
reserved words for your own purposes can leads to lots of problems.
 
That should work. You sure iMonth is the correct value? Is VanID a
text field? (If so, you need quotes around the value).

BTW, Date is a bad choice for a field name: it's a reserved word, and
using reserved words for your own purposes can leads to lots of
problems.

You're right it does work now. I changed a couple of things, one being
changing the field Date to EntryDate.

Thanks
 
Back
Top