Where is it wrong

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

Guest

I write this code in my form it work good

Text2 = DCount("holiday", "holidaydate", "[holiday] between #1/1/2006# and
#31/1/2006#")

When I change to this it not work
Text2 = DCount("holiday", "holidaydate", "hlidaydate.holiday between
#satartdate# and #stopdate#")

startdate and stopdate are control name in myform
 
You need to concatenate the values from the controls into the 3rd string.

Try this:

Dim strWhere As String
strWhere = "hlidaydate.holiday between #" & _
Format([satartdate], "mm\/dd\/yyyy") & "# And #" & _
Format([stopdate], "mm\/dd\/yyyy") & "#")
Text2 = DCount("holiday", "holidaydate", strWhere)

Please note that your first example would not work if you used dates
2/1/2006 and 10/1/2006, because Access would interpret that as February 1 to
October 1. For details on how to ensure Access does not misunderstand your
d/m/y dates, see:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html
 
Hi Nova,

Try this instead (and verify that the spelling of your field and table names
are correct, ie. "satartdate" and "hlidaydate"):

Text2 = DCount("holiday", "holidaydate", "hlidaydate.holiday between #" &
satartdate & "# And #" & stopdate &"#")


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

I write this code in my form it work good

Text2 = DCount("holiday", "holidaydate", "[holiday] between #1/1/2006# and
#31/1/2006#")

When I change to this it not work
Text2 = DCount("holiday", "holidaydate", "hlidaydate.holiday between
#satartdate# and #stopdate#")

startdate and stopdate are control name in myform
 

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