Results 1 to 9 of 9
  1. #1
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56

    Dcount on Query design

    Hi Im trying to count records, in time shift for a specific field, i use this code into the query desing and give me error

    QUERY DESIGN

    Field



    TESTCOUNT("*", "[Employers]", "[timeshift] BETWEEN #7:00# AND #15:00#")

    What is the wrong with it?

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    timeshift is a date/time field? Not sure, as this worked for me:

    ?dcount("*", "tblReservations", "TimeValue(ReqDateTime) Between #8:00# And #11:00#")
    12

    In my case the field contains a date and time value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Hi Pbaldy,, yes it is.. actually i want to count time shift based on 24 7-15, 15-23, and 23.00-7.00am...

    ill try it and let you know..

  4. #4
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    Can you sent me the accdb file?, seems, i cant make it work
    Thanks

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    It would make more sense for you to post your db with the failing effort. I tested in a production db that I wouldn't be able to post anyway.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    timeshift-count.accdb

    Here is the file

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Sorry, the question mark was because I was testing in the Immediate window. You also still had my field name. This works:

    SELECT tblReservations.Surname, tblReservations.Timeshift, DCount("*","tblReservations","TimeValue(timeshift) Between #7:00# And #15:00#") AS Eκφρ1
    FROM tblReservations;
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    thanosgr is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2012
    Posts
    56
    thanks it works, but its shows all the record, how can it shows only the records that match the timeshift between 7 and 3

    Thanks

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You would need a WHERE clause in you query (criteria in design view). It would basically be the same as the criteria in the DCount.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Query design help
    By claudia_lovez_u in forum Access
    Replies: 9
    Last Post: 04-19-2012, 07:33 PM
  2. DCount Items in query field
    By rdr910 in forum Queries
    Replies: 7
    Last Post: 03-02-2012, 05:31 PM
  3. Dcount query
    By ramdandi in forum Queries
    Replies: 1
    Last Post: 12-27-2011, 01:30 PM
  4. Query Design Question
    By copegjc15 in forum Queries
    Replies: 7
    Last Post: 11-13-2010, 10:28 PM
  5. multiple dcount update query
    By slothnet in forum Programming
    Replies: 5
    Last Post: 08-24-2010, 03:44 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