Results 1 to 10 of 10
  1. #1
    jessica.ann.meade is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    8

    Exclamation Trouble with DCount syntax.

    I have a table that tracks the "out of office workdays" of staff members by type of work day. Currently there are two options to choose from.

    I have created a report that groups the occurence of each type of workday by staff member, with a count of the number of occurences per staff member.
    For example:
    Staff Member A
    Type: Telework
    Occurence 1 Telework
    Occurence 2 Telework
    Total Telework Days: 2

    Type: Bi-weekly Alternative Work Schedule


    Occurence 1 BAWS
    Total BAWS Days: 1


    Staff Member B
    ......etc.
    At the close of the report I want to have a cumulative total of the number of occurences of each type throughout the query. I know that I can count occurences by record using DCount(expr, domain, criteria) but I am having trouble with the syntax and keep receiving an error when I run the report.

    The function I have been using looks like this:
    DCount([Type], 'Alternate Work Schedule', ([Type]='Alternate Work Schedule'))
    Where [Type] is the field with the necessary records; 'Alternate Work Schedule' is the domain for the values I want counted; and the criteria is that [Type]='Alternate Work Schedule'.

    What have I done incorrectly?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    *All* arguments for the Domain Functions are strings: http://www.mvps.org/access/general/gen0018.htm

  3. #3
    jessica.ann.meade is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    8
    Ok...
    using the string I changed the function to look like this:

    DCount(([Telework Tracking].Type), [Telework Tracking], 'Alternate Work Schedule')

    and have also tried:

    DCount(([Telework Tracking].Type), [Telework Tracking], ([Telework Tracking].Type)='Alternate Work Schedule')

    where ([Telework Tracking].Type is a field that appears in both a table and query; and [Telework Tracking] is the table.


    Now I am being prompted to enter parameters for "Telework Tracking" when generating the report and am given a "#Name?" error, even when I enter 'Alternate Work Schedule' as the parameter.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Yoy are still *not* using strings!
    DCount("Argument1","Argument2","Argument3")

  5. #5
    jessica.ann.meade is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    8
    Thanks, you're so helpful!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you get it to work?

  7. #7
    jessica.ann.meade is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    8
    No, I did *not*.
    You keep telling me I'm not using strings, when I am creating the function based on what every Access site has said a DCOUNT statement should look like, but you are sending me to a tutorial on how to build a DLOOKUP statement. I know the two are related, but I also know they are used for different purposes, and you are not giving me any kind of real explanation as to what my function *SHOULD* look like.

    I thank you for trying, anyways.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Strings begin and end with quotes. You seem just a bit miffed. Try:
    DCount("[Type]", "[Telework Tracking]","[Type]='Alternate Work Schedule'")
    ...and you should *not* use [Type] as the name of any object since it is a reserved word: http://www.allenbrowne.com/AppIssueBadWord.html#T

  9. #9
    jessica.ann.meade is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    8
    Yes, I'm sorry I was getting annoyed. The quotation-factor was not registering in my brain. I understand that [Type] is a reserved word, but in my case it is not posing a problem. I did add the quotations and now the function is working. I do thank you for your help, and apologize if I was rude.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It can be a bit frustrating at times on my side as well. Go ahead and use the Thread Tools and mark this thread as Solved if you feel it is.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. dcount syntax correct?
    By lbgtp in forum Reports
    Replies: 2
    Last Post: 12-29-2010, 10:01 AM
  2. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  3. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  4. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 AM
  5. DCount realtime
    By Patience in forum Access
    Replies: 2
    Last Post: 06-24-2010, 06:20 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