Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

DCount

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 26 Jul 2005 14:02 GMT
Hello all,

My between date is not working and I guessing my syntax is off.  Grrrr
syntax!  The cal1 and 2 is from two calendars on my form.  Thanks!

vSql = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD Between #" &
cal1 & "# And #" & cal2 & "#")
Rick Brandt - 26 Jul 2005 14:14 GMT
> Hello all,
>
[quoted text clipped - 3 lines]
> vSql = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD
> Between #" & cal1 & "# And #" & cal2 & "#")

Syntax looks good to me.  Does it work if you substitute hard values for
cal1 and cal2?

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Mark - 26 Jul 2005 14:21 GMT
Yes, it does.  This works

vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD Between
#07/01/2005# And #07/24/2005#")

> > Hello all,
> >
[quoted text clipped - 6 lines]
> Syntax looks good to me.  Does it work if you substitute hard values for
> cal1 and cal2?
Rick Brandt - 26 Jul 2005 14:27 GMT
> Yes, it does.  This works
>
> vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD Between
> #07/01/2005# And #07/24/2005#")

Then cal1 and cal2 must not contain valid date values or else not the date
values you think they do.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

Mark - 26 Jul 2005 15:10 GMT
I used a text box instead of Cal and it did work, so looks like some format
issue.  

However, I'm still getting some errors in my data from the field being (in
the table) a combination of Date and time.  Ex: 07/25/2005 5:09:35 PM

When I run:
vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD = #07/13/2005#"

It shows none.  What would I use to only see the date in a field?

> > Yes, it does.  This works
> >
[quoted text clipped - 3 lines]
> Then cal1 and cal2 must not contain valid date values or else not the date
> values you think they do.
Rick Brandt - 26 Jul 2005 15:36 GMT
> I used a text box instead of Cal and it did work, so looks like some
> format issue.
[quoted text clipped - 8 lines]
>
> It shows none.  What would I use to only see the date in a field?

There's the "easy but inefficient" method...
vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DateValue(DTIMEMOD) =
#07/13/2005#"

And there's the more difficult but more efficient method...
vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD BETWEEN
#07/13/2005# AND #7/14/2005#")

If you think there's any chance of having records with exactly midnight then
you have to use...
vStr = DCount("WORK_REQ_ID", "VIAWARE_WCS_TO_VIA_T", "DTIMEMOD BETWEEN
#07/13/2005# AND #7/13/2005 23:59:59#")

The efficiency issue is that you (whenever possible) want to apply criteria
to a field directly rather than to an expression containing the field.  The
latter prevents the database engine from being able to utilize an index
forcing a row by row table scan.

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.