Results 1 to 5 of 5

Thread: DCount (97)

  1. #1
    Lounger
    Join Date
    Aug 2001
    Location
    Toronto, Ontario, Canada
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DCount (97)

    Greetings All : <img src=/S/brainwash.gif border=0 alt=brainwash width=15 height=15>

    I am trying to use DCount to determine if a query returns any records. If it doesn't I am OK to continue with whatever. However, if it does return a record the process must stop.

    The code I am using is :

    If (DCount("Orders", "qryBillings02d-Check-YTDManual-DoubleUps",0)) Then
    continue
    Else
    stop
    End If

    I have also tried If IsNull(DCount("Orders", "qryBillings02d-Check-YTDManual-DoubleUps")) but without success.

    If anyone could give any help on this it would be much appreciated. I am fuddled. TIA. DT

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount (97)

    Try DCount as follows:
    DCount("[your fieldname to Count]","[qryBillings02d-Check-YTDManual-DoubleUps]",add any criteria you want in quotes) = 0 Then ...

    The idea is that you want to check that the entire DCount statement = (or maybe <>) 0, not include the 0 within the DCount statement. Make sure your fieldname is a field in the query that will not be Null.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: DCount (97)

    >>(DCount("Orders", "qryBillings02d-Check-YTDManual-DoubleUps",0)) <<

    First of all, you specified a selection criteria. Essentially you said "Count the number of records that contain a non-null value for [Orders] in the recordset returned by qryBillings...etc., where FALSE.

    Try this instead:

    If DCount( "*", "qryBillings.....") = 0 Then

    The '*" is faster, and counts all records in recordset.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Lounger
    Join Date
    Aug 2001
    Location
    Toronto, Ontario, Canada
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount (97)

    Thank you. That's the ticket.

  5. #5
    Lounger
    Join Date
    Aug 2001
    Location
    Toronto, Ontario, Canada
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DCount (97)

    thanks to you both.

Posting Permissions

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