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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup - Multiple Criteria including Date 1

Status
Not open for further replies.

Xenophobia

Technical User
Apr 7, 2003
18
US
I am working on a DSum actually, but they have the same variables and formats I believe.

I'll just paste the code I have right now:

"

=DSum("hours","timeRecord","empNumber=" & (Forms!mainApp!txtEmpId) And "dataDate=" & (Forms!mainApp!calendar))

"

Anyways, I'm not much of an Access Guru but rather work well with SQL queries and the like. So when I have to update a text field (which this DSum is the control source of) I get stumped at the syntax required... ESPECIALLY after googling and looking around at all the Quotes and Single Quotes that are required...

Anyways, you can tell I am trying to cross-reference an Employee Number through a field on my form as well as a date that will be selected by a user (on the same form, "mainApp") My real question is if anyone would know how to format the quotes around this DSum so that it actually WORKS?

Thank you,

~ Xenophobia
 
Code:
=DSum("hours","timeRecord","empNumber='" & Forms!mainApp!txtEmpId & "' AND dataDate=#" & Forms!mainApp!calendar & "#")
If empNumber is defined as numeric in timeRecord then get rid of the single quotes.

Another way to try:
Code:
=DSum("hours","timeRecord","empNumber=[Forms]![mainApp]![txtEmpId] AND dataDate=[Forms]![mainApp]![calendar])

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The first code snippet you gave me (after removing the single quotes, because yes, empNumber is defined as numeric) worked perfectly.

I greatly appreciate your fast, precise responses to my posts!

Thank you, again!

~ Xenophobia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top