Dcount function in query not work?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to find number of days between two dates form Table Holiday with
condition from TblVac (StartVac and StopVac field)
One field in query I type
Vacationdays:DCount("Dayoff","Holiday","Holiday.Dayoff between #" &
(TblVac.StartVac]) & "# and #" & ([TblVac.StopVac]) & "#"))
When I run this query, No any error message, Other fields work OK, but
result in vacation days is "0" all record Why?

After that I try to create form (testform) and then write code
Vacationdays= DCount("Dayoff","Holiday","Holiday.Dayoff between
Forms!Testform.StartVac and Forms!Testform.StopVac")
It works, I don't understand
 
Guessing that you live in a country that doesn't use US date format. Jet SQL
expects US format for dates, so try this:

Vacationdays:DCount("Dayoff","Holiday","Holiday.Dayoff between #" &
Format(TblVac.StartVac],"mm\/dd\/yyyy") & "# and #" &
Format([TblVac.StopVac],"mm\/dd\/yyyy") & "#"))
 
Thankyou for your answer.
I live in Thailand SouthEast Asia, my access2003 need to use Thai calendar.
I follow your code, but still not work
I ever try code from www.mvp.org/aceess/datetime in Calculate Number of
Workingdays, also not work (Function Workingdays OK, Function Workingdays2
Not OK)

Help me again please.
Other function date/time such as Datediff, Date(), Now() work normal in
query.
 
Found a typo in my post:

Vacationdays:DCount("Dayoff","Holiday","[Holiday.Dayoff] between #" &
Format([TblVac.StartVac],"mm\/dd\/yyyy") & "# and #" &
Format([TblVac.StopVac],"mm\/dd\/yyyy") & "#"))
 

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

Back
Top