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

criteria not working

Status
Not open for further replies.

vttech

Technical User
Jan 28, 2006
297
US
I am trying to get login and logout time as it relates to an employeeid and the Start and End dates of a pay period from table tbllogInOut. The first part of the criteria works fine in regards to the employeeID but I am having trouble with the start and end dates of the pay period. The statement below is what I have in a text box control source


Code:
=Format(DSum("(([logout]-[login])*24)","tblLogInOut",[employeeID]=Reports!rptBiWeekly!txtEmployeeID And ([workdate] Between Forms!frmloginout!txtStartDate And Forms!frmloginout!txtEndDate)),"#.00")

This is the portion of the statement that is not functioning because it's giving be the total hours of all data inputted in the table instead of basing it on the criteria I want.

Code:
And ([workdate] Between [Forms]![frmloginout]![txtStartDate] And [Forms]![frmloginout]![txtEndDate])

Any ideas on how to resolve this issue?


Newbie in search of knowledge
 
You need to delimit the date criteria with # signs.
Try using this:

And ([workdate] Between #" & [Forms]![frmloginout]![txtStartDate] & "# And #" & [Forms]![frmloginout]![txtEndDate] & "#")
 
john thanks I tried your approach and got syntax error. so I tried

Code:
=Format(DSum("(([logout]-[login])*24)","tblLogInOut","[employeeID]=Reports!rptBiWeekly!txtEmployeeID And ([workdate] Between & '#' & Forms!frmloginout!txtStartDate & '#' & And & '#' & Forms!frmloginout!txtEndDate & '#'")),"#.00")

But I am still receiving syntax error message any ideas?

Newbie in search of knowledge
 
Try This:

=Format(DSum("(([logout]-[login])*24)","tblLogInOut","[employeeID]= " & Reports!rptBiWeekly!txtEmployeeID & " And [workdate] Between & #" & Forms!frmloginout!txtStartDate & "# And #" & Forms!frmloginout!txtEndDate & "#"),"#.00")
 
John's replay has an extra "&" after Between.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks dhookom.....

This is the correct one:

=Format(DSum("(([logout]-[login])*24)","tblLogInOut","[employeeID]= " & Reports!rptBiWeekly!txtEmployeeID & " And [workdate] Between #" & Forms!frmloginout!txtStartDate & "# And #" & Forms!frmloginout!txtEndDate & "#"),"#.00")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top