Results 1 to 6 of 6
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    dcount for multiple criteria

    got a problem "somewhere",
    ...and starting to second guessing myself



    just to be certain, the below code does check that there is at least one single record in the table where both of the conditions are true;
    (not that there is at least one record that satisfies one criteria, and another (not necessarily same record) that satisfies the other criteria...


    Code:
        Dim vCNote_ID as Inteeger
        Dim vCNote_Descript As String
        dim vCNote_ChxBox_Field as String
        Dim vCNote_CntEOS As Integer
        Dim vCNote_CntReqd As Boolean
    
            vCNote_Descript = DLookup("[CNote_Title]", "tblCNotes_EOS", "[CNote_ID]= " & vCNote_ID)
            vCNote_ChxBox_Field = DLookup("[CNote_chkbox_Field]", "tblCNotes_EOS", "[CNote_ID]= " & vCNote_ID)
    
            vCNote_CntEOS = DCount("[CNote_ID]", "tbeCoordinationNotes_EOS", "[CNote_ID]= " & vCNote_ID)
            vCNote_CntReqd = DCount("[Type]", "tbeFixtureTypeDetails", "[ContractorToCoordYN] And [" & vCNote_ChxBox_field & "]") > 0

    with appreciation in advance,
    mark

  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,518
    What's the question, or the error, or the problem? This looks odd, like the "And" should be "=""

    vCNote_CntReqd = DCount("[Type]", "tbeFixtureTypeDetails", "[ContractorToCoordYN] And [" & vCNote_ChxBox_field & "]") > 0
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    Checking for a record where BOTH conditions are true, not that one condition = the other

    ...and I’m not getting an accurate result...
    The problem “might” be here, but it might be “somewhere” else

    At the moment. ....I’m chasing my tail, looking for a new pony to ride

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This type of thing:

    "[CNote_ID]= " & vCNote_ID & " And FieldName = " & Variable
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    not to worry
    found the problem (and as suspected... it was elsewhere)

    I have to admit, sometimes, the insight of trying to state the problem with clarity (i.e. post a eligible, understandable, accurately stated new discussion), lends insight into the problem itself;
    Now, I do try not to ... within the forum; but sometimes ...
    and for that I really am appreciative (especially, since I'm probably the only one in my office who can even pronounce VB or SQL, never-mind there be another person who I can bounce a quandary off of.)

    Or more simply put: "sometimes the very action of asking... answers"

    m.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you found the problem.
    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. Dcount function with multiple criteria
    By eusebio in forum Forms
    Replies: 1
    Last Post: 11-23-2018, 04:45 PM
  2. DCount Multiple Criteria Not Working
    By seantnash in forum Queries
    Replies: 6
    Last Post: 08-19-2016, 02:40 PM
  3. Replies: 2
    Last Post: 02-26-2014, 05:06 PM
  4. DCount with Multiple Criteria
    By Newbie11 in forum Reports
    Replies: 4
    Last Post: 05-25-2012, 09:04 AM
  5. How do you use DCOUNT for multiple criteria?
    By wwhit in forum Programming
    Replies: 5
    Last Post: 05-15-2012, 11:14 AM

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