Results 1 to 8 of 8
  1. #1
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164

    Record Count based on Form control value

    Hello Everyone,

    I know this shouldn't be too difficult, I've just been so mired in other tasks that I feel my Access skills leaking out of my head. Therefore feel free to let me know how simple this is and how I should have figured it out already.

    The general situation:
    I have a form where my users enter information about customers into a table (pretty straight forward, right?). Each customer has a unique ID by which we identify them, however they may have multiple records on this table if there are multiple issues.

    Specific Issue:
    I want to construct a record count textbox or combobox (whichever is easier) on the form that will display the number of records a customer has in the table. I want the criteria to the value in the ID textbox. So basically, there may be 30 records in the table but customer 5 only has 2 records. When I navigate in the form to either of those two records I want the record count to display 2. When I am entering a new record, once I've entered the ID and navigated to another control, the record count should update to reflect the creation of the new record.



    I've tried simple stuff like =Count([ProbTracker].[ID] = [ID]) for a text box data source. It always gives me the total number of records.

    I eventually want to use this criteria ([ProbTracker].[ID]=[Form].[ID]) in a SQL statement so I can generate a small report that would show each record specific to that customer. I figure I'll use some DAO or ADO recordset code to help me out there.

    Any and all eventual help is much appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Simplest is probably a DCount() with the appropriate criteria:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848

  4. #4
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    I am sorry if I was unclear, I do have a separate Customers and CustomerIssues table. In fact I have multiple Customer Issues tables due to all the different fields that apply to only specific issue types. This is a small aspect of a larger system.

    With respect to DCount, I thought that was only for unique values. I'm looking for repeats, including the record I am on. I have the current expression in the Control Source "=DCount("SMARTID","ProbTracker","SMARTID=" & [Forms]![ProbTrackfrm]![SMARTID]) " and it returns a 0 regardless of the number of records that actually match the SMARTID on the form.

  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,640
    This should work if SmartID is the field identifying the customer:

    =DCount("*","ProbTracker","SMARTID=" & [Forms]![ProbTrackfrm]![SMARTID])
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Unfortunately in this case the operative word is "should". The SMARTID is the field that identifies the customer but the formula you gave me, when used as the data source for a text box, returns a 0 for all instances. This is true no matter how many records a customer has in the table ("ProbTracker"). Also when I try to use the formula as part of a combo box query I still get 0 for all SMARTIDs. Perhaps we could use a DAO or ADO recordset with an appropriate SQL statement?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Sure. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Monterey_Manzer is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    164
    Sadly, both the db size and the sheer volume of protected information make posting the db frighteningly prohibitive.

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

Similar Threads

  1. Replies: 5
    Last Post: 08-03-2012, 04:20 PM
  2. Replies: 2
    Last Post: 06-05-2012, 12:33 PM
  3. Query based on current record in form
    By bhsvendbo in forum Queries
    Replies: 1
    Last Post: 06-01-2010, 11:20 AM
  4. export Excel control row count
    By TheShabz in forum Code Repository
    Replies: 1
    Last Post: 04-17-2010, 12:00 AM
  5. Form Record Count
    By Texaine in forum Forms
    Replies: 0
    Last Post: 10-19-2006, 09:07 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