Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Correct DCount Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    I have a form with Text Box with the following code in the Control Source:

    The works OK, however now I want to refine it so it only returns a count of unique strRefNo

    How do I change the following code?

    Thanks, John

    <pre>=Nz(DCount("strRefNo","qrytbl_RevTran_MasterD etail",
    "dtmRevDate >= #" & [StartDate] & "# and dtmRevDate <= #" & [EndDate] &
    "# and RevCode Between " & Chr(34) & GetPref("GOC Code BJLF Start") & Chr(34) &
    " And " & Chr(34) & GetPref("GOC Code BJLF End") & Chr(34)),0)
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need Correct DCount Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You need to create a query that returns the unique strRefNos. The SQL for this query will look like this:

    SELECT DISTINCT strRefNo
    FROM qrytbl_RevTran_MasterDetail
    WHERE dtmRevDate Between [Forms]![FormName]![StartDate] And [Forms]![FormName]![EndDate] AND RevCode Between GetPref("GOC Code BJLF Start") & And GetPref("GOC Code BJLF End")

    Save this query as, say, qryRefNos

    You can then use the expression

    =DCount("*","qryRefNos")

    to return the count of unique strRefNos. You'll have to recalculate the form (Me.Recalc) to update the text box.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Correct DCount Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Thanks, works great

Posting Permissions

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