Results 1 to 12 of 12
  1. #1
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58

    Showing Count in form field

    I have a form with a Total field and I am needing to show a count of all the records with the same Name and Date as the record that is currently selected



    I am not sure where to began to get the total or have it change as I go from record to record.

  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,652
    You can probably use a DCount:

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

  3. #3
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    Please pardon my ignorance. I looked at the samples and I am not sure how to get it to work for both a date field and a text field.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Did you notice the "mix and match" sample at the bottom? All you need to do is delete the numeric part.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    I tried the mix and match and here is what I tried with no luck

    =DCount("Name", "EmployeeTable", "[Name] = '" & Forms![EmployeeTable]![Name] & "'" _
    & " AND [Date] =#" & Forms![EmployeeTable]![Date] & "#")

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That looks okay offhand, though I would eliminate the extra concatenation and put the trailing single quote in the next line (personal preference, plus a tic faster). Name and Date are not good field names, since they can conflict with built-in properties and functions. Not sure if that's the problem here, but if it's not too late to change them I would. Can you post the db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    Here is the sample database.

    I have changed the names and here is the new code.

    =DCount("Employee_Name", "Employee_Table", "[Employee_Name] = '" & Forms![Employee_Table]![Employee_Name] & "'" _
    & " AND [Todays_Date] =#" & Forms![Employee_Table]![Todays_Date] & "#")

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Your names don't contain underscores, they contain spaces, which are also a bad idea. This works as the control source of the textbox:

    =DCount("Employee_Name","Employee Table","[Employee Name] = '" & [Forms]![Employee Table]![Employee Name] & "' AND [Todays Date] =#" & [Forms]![Employee Table]![Todays Date] & "#")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    ok thanks! I did input that into the Control Source of the textbox and I am receiving a #Error in the text box.

    Any thoughts as to why it is giving a error?

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

  11. #11
    randolphoralph is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Dec 2008
    Posts
    58
    I see why I was getting the error. I had not taken all the underscores out. Thank you so much.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No problemo.
    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. Replies: 2
    Last Post: 02-13-2010, 01:54 PM
  2. Startup form not showing?
    By cfasoftware in forum Access
    Replies: 1
    Last Post: 01-21-2010, 03:10 AM
  3. people from table not showing in form
    By corystemp in forum Access
    Replies: 2
    Last Post: 03-26-2009, 08:57 PM
  4. How to count charcter or text in field
    By nshaikh in forum Queries
    Replies: 3
    Last Post: 09-12-2008, 10:27 AM
  5. Txt box on form showing 'Balance'
    By wasim_sono in forum Programming
    Replies: 1
    Last Post: 04-25-2006, 05:58 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