Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2009
    Location
    UK
    Posts
    44

    Unanswered: Dcount help please

    Hi guys i am having trouble with this dcount function.

    What i am aiming to do is count the records in a query (which i can do) but the criteria needs to be based on the value of another query.

    Code:
    If DCount("*", "qryeventsbookedpm", "[StartDate] =  " & MakeUSDate(Me("day" & X)) & "") >= 2 Then
    The above works but what i want to do is change the ">= 2" to pick up a value in another query

    Code:
    If DCount("*", "qryeventsbookedam", "[StartDate] =  " & MakeUSDate(Me("day" & X)) & "") >= [qryeventsbookedmaxzoneslots]![LastOfamslots] Then
    I dont know how to format the last bit. Any help would be appreciated.

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Quote Originally Posted by leebaggaley View Post
    Hi guys i am having trouble with this dcount function.

    What i am aiming to do is count the records in a query (which i can do) but the criteria needs to be based on the value of another query.

    Code:
    If DCount("*", "qryeventsbookedpm", "[StartDate] =  " & MakeUSDate(Me("day" & X)) & "") >= 2 Then
    The above works but what i want to do is change the ">= 2" to pick up a value in another query

    Code:
    If DCount("*", "qryeventsbookedam", "[StartDate] =  " & MakeUSDate(Me("day" & X)) & "") >= [qryeventsbookedmaxzoneslots]![LastOfamslots] Then
    I dont know how to format the last bit. Any help would be appreciated.
    Hi

    I don't profess to understand your user defined function but, taking that as read, I would suggest somethink like this

    Code:
    If DCount("*", "qryeventsbookedam", "[StartDate] =  " & MakeUSDate(Me("day" & X)) & "") >= DLookUp("LastOfamslots","qryeventsbookedmaxzoneslots") Then
    This assumes that there is only one record returned by 'qryeventsbookedmaxzoneslots' ?


    MTB

  3. #3
    Join Date
    Nov 2009
    Location
    UK
    Posts
    44
    amazing, that works perfectly

    I cant thank you enough, i have been stressing over this for the last 4 hours lol


    Thanks very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •