Results 1 to 11 of 11
  1. #1
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16

    Display a number of records in a query on a form

    I have a Table (Client_Details) containing all records of customers. Some of these account are open, some are closed.

    I also have a query (open_accounts) which just selects accounts with a status of Open.

    As accounts are open and closed, I would like to display on my main form a number of current live Open accounts in real time, basically summing the total number of records returned at any given time by the query.

    I have inserted a text box on my Form to display, and have tried a number of different ways to have this data display, but keep running into errors or invalid syntax. I have searched everywhere and tried a number of solutions, none of which seem to be working.



    Help is much appreciated!

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    The easiest way would be a DCount() . On your text box try something like;
    Code:
    =DCount("*","YourOpenAccountQueryName")
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16
    Thanks. All I get for that is #Name? returned.

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Okay, so what have you actually put in the control?
    And what is the name of your query ? And to save another reply , what is the SQL of your open account query ?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16
    I have copied your code exactly, save for changing the name of the query to open_accounts, as I specified in my original post.

  6. #6
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16
    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	22.4 KB 
ID:	36280

    There is SQL view. I have blacked out customer info.

  7. #7
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Okay try specifying the ID ;

    =Dcount("ID","open_accounts")

    As a bit of advice (before changing things would become a real pain) although Access allows it, starting field or table names with numbers isn't allowed in SQL Server or many other DBMS.
    So a table called 1_client_details wouldn't work if you ever upsized to SQL server.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    =Dcount("ID","[1_clients_details]","[Account Status] = 'Open'") ?

    Agree that names starting with numbers is to be avoided - even more so than spaces or special characters.
    I'm surprised the sql would work as there is an instance of the table name that isn't bracketed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16
    You guys are my heroes! that's sorted it. And thank you for the advice, I will change that. I am quite new to it all, so appreciate the help.

  10. #10
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Not sure which worked.
    As a self proclaimed newbie, you might want to check out these subjects - if these particular links don't grab your attention, maybe find your own. I think it's the subjects themselves that are the most important.

    Normalization is paramount. Diagramming maybe not so much for some people.

    Normalization Parts I, II, III, IV, and V
    http://rogersaccessblog.blogspot.ca/...on-part-i.html
    and/or
    http://holowczak.com/database-normalization/

    Entity-Relationship Diagramming: Part I, II, III and IV
    http://rogersaccessblog.blogspot.ca/...ng-part-i.html

    How do I Create an Application in Microsoft Access?
    http://rogersaccessblog.blogspot.ca/...cation-in.html

    Important for success:
    One source about how to name things - http://access.mvps.org/access/general/gen0012.htm
    What not to use in names - http://allenbrowne.com/AppIssueBadWord.html
    About Auto Numbers
    - http://www.utteraccess.com/wiki/Autonumbers
    - http://access.mvps.org/access/general/gen0025.htm

    The evils of lookup fields - http://access.mvps.org/access/lookupfields.htm
    Table and PK design tips - http://www.fmsinc.com/free/newtips/primarykey.asp
    About calculated table fields - http://allenbrowne.com/casu-14.html

  11. #11
    rocknmoll is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2018
    Posts
    16
    Wow, thank you so much. That will be really useful. Again, really appreciate the help.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-02-2015, 02:23 PM
  2. Replies: 3
    Last Post: 07-24-2015, 11:24 AM
  3. Display XX number of records per page
    By cactuspete13 in forum Forms
    Replies: 11
    Last Post: 07-19-2014, 05:17 AM
  4. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  5. Replies: 6
    Last Post: 07-25-2011, 01:54 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