Results 1 to 5 of 5
  1. #1
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39

    DCount failing with multiple parameters

    Hi,

    I am trying to error catch wether a query is an empty record set. It has 2 parameters, 1 querying the TxtTransactionType field and 2 a between Date range entered from a form. My statement below is not working. I have changed the syntax numerous times and it doesn't error out but my Query is always empty even when it should not be.
    I put a me.requery before I ran the test and it returned data to the form. But then popped up the message box with my error message for "no records found" then cleared my form....(which is what it is suppose to do when it returns no records). Everything I have researched says I should be able to do this.

    I have another form which queries totals for all transactions and that statement is working fine. But the minute I add the TxtTransactionType into the mix I have problems. The Used_Date is the date range the start and end date queries. This works fine.

    If DCount("Used_Date", "Query Transaction Type", "TxtStartDate=#" & Me.TxtStartDate & "# AND TxtEndDate=#" & Me.TxtEndDate & "#") = 0 Then


    I have tried both formats below but to no avail: I put the "*" in place of the Used_date because when I use Used_date it errors out. Don't understand why I can't count the Used_Date even though I have 2 parameters.

    If DCount("*", "Query Transaction Type", "TxtTransactionType=' & Me.TxtTransactionType & ' AND TxtStartDate=#" & Me.TxtStartDate & "# AND TxtEndDate=#" & Me.TxtEndDate & "#") = 0 Then

    If DCount("*", "Query Transaction Type", "TxtTransactionType='Me.TxtTransactionType' AND TxtStartDate=#" & Me.TxtStartDate & "# AND TxtEndDate=#" & Me.TxtEndDate & "#") = 0 Then



    Help please.

  2. #2
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39
    Oh one typo there.....in the first statement the Query Name is "Query Total by Month"

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    ssalem is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Feb 2013
    Posts
    39
    Wow....I just figured it out....the one syntax I did not use.

    If DCount("*", "Query Transaction Type", "TxtTransactionType='" & Me.TxtTransactionType & "' AND TxtStartDate=#" & Me.TxtStartDate & "# AND TxtEndDate=#" & Me.TxtEndDate & "#") = 0 Then

    I had tried the " & me.TxtTransactionType & " but did not include both sets of quotes. " to contain the grouping and ' to define the string. I just tried it and now it works. Thanks for the link though on Dlookup. Will help in the future I am sure.

    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,652
    Happy to help!
    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 with Multiple Criteria
    By Newbie11 in forum Reports
    Replies: 4
    Last Post: 05-25-2012, 09:04 AM
  2. How do you use DCOUNT for multiple criteria?
    By wwhit in forum Programming
    Replies: 5
    Last Post: 05-15-2012, 11:14 AM
  3. Query with multiple parameters
    By Knaabis in forum Access
    Replies: 2
    Last Post: 06-30-2011, 01:15 AM
  4. Multiple parameters collected in a query
    By Joe Heiser in forum Queries
    Replies: 4
    Last Post: 02-16-2011, 04:29 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