Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a DLookup Function with the System Date

Status
Not open for further replies.

jaaret

Instructor
Jun 19, 2002
171
0
0
I know there must be multiple threads on this: how do you use the system date in a VBA fuction? The following results in, "Invalid use of null."

Dim DateToday As Date

DateToday = Date

RemDayNum = DLookup("RemDays", "tlkpRemDays", "DateCal=" & DateToday)

Thank you,
Jaaret
 
Where/how did you Dim RemDayNum? Why are you creating a date variable with the value of Date?

Have you confirmed there are matching records? You could use a query like:

SQL:
SELECT RemDays FROM tlkpRemDay WHERE DateCal = Date();

You may need to use something like:
Code:
RemDayNum = DLookup("RemDays", "tlkpRemDays", "DateCal=#" & DateToday & "#")

Duane
Hook'D on Access
MS Access MVP
 
Thanks, Duane. The VBA suggestion with the hashtags did the trick.

Jaaret
 
jaaret, if you have found dhookom's post helpful, especially if it solved your problem, it is customary on TT to use
[blue]
Like this post?
Star it![/blue]


To show appreciation for the help received, and also the little star help others to see which post was the solution.


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top