Combining 2 DCounts

D

DS

How can I combine these to DCounts into one? Is there an or that I can add?

Me.TxtCount = DCount("[MenuID]", "MenuDetails", _
"MenuDetails.TerminalID = " & Forms!Patrons!TxtPatTermID & _
" AND MenuDetails.StartDay = Forms!Patrons!TxtDay " & _
" AND MenuDetails.StartTime <= #" & Time() & "#" & _
" AND MenuDetails.EndTime >= #" & Time() & "#" & _
" AND MenuDetails.Active = -1 " & "")

Me.TxtCount = DCount("[MenuID]", "MenuDetails", _
"MenuDetails.TerminalID = " & Forms!Patrons!TxtPatTermID & _
" AND MenuDetails.StartDay = Forms!Patrons!TxtDay-1 " & _
" AND MenuDetails.StartTime >= #" & Time() & "#" & _
" AND MenuDetails.EndTime >= #" & Time() & "#" & _
" AND MenuDetails.Active = -1 " & _
" AND MenuDetails.AfterMidnite = -1 " & "")

The only difference is the StartTime and the addition of the last line
on the second one. Any help appreciated.
Thanks
DS
 
S

Steve Schapel

DS,

Is StartDay a date? If so, you should have it properly delimited. I
will assume that it is. Also I could not see the purpose of the & "" at
the end so ignore that. So, off the top of my head, something like this?...

Me.TxtCount = DCount("*", "MenuDetails", _
"MenuDetails.TerminalID = " & Forms!Patrons!TxtPatTermID & _
" AND MenuDetails.EndTime >= #" & Time & "#" & _
" AND MenuDetails.Active = -1" & _
" AND ((MenuDetails.StartDay = #" & Forms!Patrons!TxtDay & "#" & _
" AND MenuDetails.StartTime <= #" & Time & "#)" & _
" OR (MenuDetails.StartDay = #" & Forms!Patrons!TxtDay - 1 & "#" & _
" AND MenuDetails.StartTime >= #" & Time & "#" & _
" AND MenuDetails.AfterMidnite = -1))")
 
D

DS

Steve said:
DS,

Is StartDay a date? If so, you should have it properly delimited. I
will assume that it is. Also I could not see the purpose of the & "" at
the end so ignore that. So, off the top of my head, something like
this?...

Me.TxtCount = DCount("*", "MenuDetails", _
"MenuDetails.TerminalID = " & Forms!Patrons!TxtPatTermID & _
" AND MenuDetails.EndTime >= #" & Time & "#" & _
" AND MenuDetails.Active = -1" & _
" AND ((MenuDetails.StartDay = #" & Forms!Patrons!TxtDay & "#" & _
" AND MenuDetails.StartTime <= #" & Time & "#)" & _
" OR (MenuDetails.StartDay = #" & Forms!Patrons!TxtDay - 1 & "#" & _
" AND MenuDetails.StartTime >= #" & Time & "#" & _
" AND MenuDetails.AfterMidnite = -1))")
Great, Thank you Steve, Start Day is a Number, End Time is a time. I
never knew you could put 2 together like that. I was just runnig them
seperate!
DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Filtered Records 1
Combining 2 Queries 2
SQL to DCount 4
ControlSource Not Working 3
DCount Syntax 6
Update Query Problem 2
UPDATE SQL Problem 1
DateDiff Problem 9

Top