Results 1 to 4 of 4
  1. #1
    Yatzek is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    5

    date variable as dCount criteria

    hi,


    where is the mistake:

    vSth = DCount("idEx", "t_Workout", "[t_Workout].[ExDate] = #" & dDefaultDate & "#")

    where of course [exDate] is date type field and dDefaultDate is date type variable.
    i thik, i've tried everythig and still got an error message,
    please help me...
    what is the right syntax??
    thanks in advance,

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    DCount("*", "t_Workout", "[ExDate]=#" & dDefaultDate & "#")

    dDefaultDate MUST be a date (not null)

  3. #3
    Yatzek is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    5
    still syntax error.

    here is full code:

    dDefaultDate = Date


    Do While DCount("*", "t_Workout", "[ExDate] = #" & dDefaultDate & "#") <> 0
    dDefaultDate = dDefaultDate + 1
    Loop

    i'm pretty sure dDeafaultdate is not null,

  4. #4
    Yatzek is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    5
    ok, i've solved it!
    there was a problem with date format

    correct syntax:
    ...
    Do While DCount("*", "t_Workout", "[ExDate] = #" & Format(dDefaultDate, "mm\ / dd \ / yyyy") & "#") <> 0
    ...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Dcount on variable Columns
    By Wagon in forum Forms
    Replies: 1
    Last Post: 04-26-2016, 05:48 AM
  2. Replies: 11
    Last Post: 03-31-2016, 09:19 AM
  3. Using DCount, how to use a variable as the criteria
    By crowegreg in forum Programming
    Replies: 2
    Last Post: 02-17-2015, 05:18 PM
  4. Dcount for 2 criteria date fields
    By rmd62163 in forum Access
    Replies: 4
    Last Post: 04-22-2014, 09:51 AM
  5. Replies: 2
    Last Post: 02-26-2014, 05:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums