Results 1 to 5 of 5
  1. #1
    RobWulf is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    2

    DCount issue

    Okay first a bit on my problem. I have a list of employees that comes in a semicolon seperated list in one field (not my choice and it has to be kept this way), and I have a list of all the employees on another table all nicely seperated out by their name and departments. I want to get a count of every time their name shows up in the list however I can't figure out how to get a count if they are part of a group that worked on something.



    My code here gives me a great count if they worked a ticket by themselves, but how do I get a count if they worked with someone else too?


    Code:
     Me.A.Value = DCount("[ticket]", "tbl_ticket", "[employeelist] Like Combo37.Value")

  2. #2
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    DCount issue

    Me.A.Value = DCount("[ticket]", "tbl_ticket", "[employeelist] Like Combo37.Value")

    Try
    Code:
    Me.A.Value = DCount("[ticket]", "tbl_ticket", "[employeelist] Like " & Combo37.Value)
    You need the combo value outside the quotes so that the value from the combo is passed the the criteria part

    If Combo37.Value = 1 then
    Code:
    Me.A.Value = DCount("[ticket]", "tbl_ticket", "[employeelist] Like 1")
    Free Tip
    http://www.599cd.com/tips/access/dco...y=AlexForumAFN

  3. #3
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    DCount issue

    You can have multiple criteria at the end too so
    A=1 AND B=2

    Replace A and B with your Field names and 1 and 2 with your variables.
    Code:
    "Field1=" & var1 & " AND Field2=" & var2

  4. #4
    RobWulf is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Posts
    2
    I tried
    Code:
     Me.A.Value = DCount("[ticket]", "tbl_ticket", "[employeelist] Like " & Combo37.Value)
    However access didn't like that too much, problem I am having is the names show as Joe Smith;Jack Bower;Tom Hanks. If I want to get just Tom Hanks in the combo box it will give me a 0 count unless his name appears by itself. How do I get the count of the other names?

  5. #5
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    DCount issue

    Have you tried splitting your string of names then adding them to the combo?

    Split(strToSplit, delimiter)

    Dim a
    a = Split("blah; blah; blah", ";")

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

Similar Threads

  1. DCount
    By Newbie11 in forum Reports
    Replies: 4
    Last Post: 08-03-2012, 12:23 AM
  2. DCount
    By Ray67 in forum Queries
    Replies: 2
    Last Post: 06-26-2012, 10:48 AM
  3. Replies: 1
    Last Post: 05-18-2012, 11:59 AM
  4. DCount and If
    By Madmax in forum Access
    Replies: 3
    Last Post: 07-28-2011, 06:53 AM
  5. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 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