Help with multiple criteria DCount and Date Field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • psuaudi
    New Member
    • Oct 2006
    • 27

    Help with multiple criteria DCount and Date Field

    I am trying to use the following code, but I think there is an error in my syntax:

    Count = DCount("[Status In]", "Change Dates", "[Status In] = '" & [Forms]![Main]![New] & "' AND CVDate(Int( #" & [Date] & "# )) = #" & (Date) & "#")

    I believe that this is the particular problem area:

    CVDate(Int( #" & [Date] & "# ))

    I've been messing with this for awhile now and it's just not working properly.

    I'm trying to count the number of occurences in the [Status In] field within "Change Dates" where the [Status In] field within "Change dates" is a particular value on the form and the [Date] field within "Change Dates" is the current date.
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Will the following not work ...

    Code:
    Count = DCount("[Status In]", "Change Dates", "[Status In] = '" & [Forms]![Main]![New] & "' AND [Date] = Date()")
    Mary

    Comment

    • psuaudi
      New Member
      • Oct 2006
      • 27

      #3
      That was actually my first course of action, but unfortunately it will not work because the [Date] field has the date stored in it as a general date (date and time) format, but I only care about comparing it to the current day. I've used the CVDate(Int([Date])) code elsewhere to parse only the date from the field, but in this instance it does not seem to want to work.

      Thank you for the reply!

      Comment

      • psuaudi
        New Member
        • Oct 2006
        • 27

        #4
        Nevermind, I finally got it to work. I swear I had tried this syntax yesterday and it didn't want to work...but this is what I ended up with.

        Count = DCount("[Status In]", "Change Dates", "[Status In] = '" & [Forms]![Main]![New] & "' AND CVDate(Int([Date])) = Date()")

        Thank you!

        Comment

        Working...