Results 1 to 4 of 4
  1. #1
    Marvinator is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Jul 2014
    Posts
    2

    Question Inventory Query in Form

    I've created a database of equipment we keep in a vault. Every so often the boss wants a count of items by model. I would like to create a button on the switchboard that can bring up this count for him.



    First I have created a query which will count by model. The SQL of that query is here:
    SELECT Count(*) AS Expr1
    FROM [Count Query]
    WHERE ((([County Query].[Model]) Like "nnn"));
    (nnn is the model number I will want and will have a diff query for each model.)

    Now, I'm trying to get these into a form for the boss to simply click. When I do, I get the #Name? error. What am I doing wrong here?

    This is my first foray into Counts and such. Anyone with a better way of handling this, please let me know.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What is it you are trying to display in your form, the count? Perhaps a domain function like DCount() is the solution.

  3. #3
    Marvinator is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Jul 2014
    Posts
    2
    Dcount works much better, but I'm havng problems in coding it right. (Sorry, really a newbie at this...)
    I need to count the records by both Model and Date In (where Date In is not Null.)

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You can use the query builder to help you with your DCount. Create a temporary query to help generate the Where criteria. For instance, typing nnn in the criteria for the Model field gives you
    WHERE ((([County Query].[Model]) Like "nnn"));

    If this was satisfactory, you could extract the needed syntax and place it in your Dcount. Start with a dcount code snippet
    Dim intCount As Integer
    intCount = DCount("", "", "")

    Then you can paste your syntax
    intCount = DCount("", "", "((([County Query].[Model]) Like ""nnn""))")

    Note that I changed
    "nnn"

    to
    ""nnn""

    Preserving quotes in a VBA string can be chalanging. The difference is adding another double quote so VBA does not think you are closing your literal text.

    Also, be sure to remove the semicolon that closes the SQL statement within the original query object.
    ));

    becomes
    ))

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

Similar Threads

  1. Need help with query - inventory
    By nightangel73 in forum Queries
    Replies: 3
    Last Post: 06-03-2014, 08:53 AM
  2. Replies: 1
    Last Post: 02-21-2013, 12:18 AM
  3. Products Inventory Dilema,Add To Inventory
    By burrina in forum Forms
    Replies: 3
    Last Post: 12-02-2012, 12:10 PM
  4. Query using inventory
    By Porksword in forum Queries
    Replies: 1
    Last Post: 12-02-2011, 06:02 PM
  5. Running an inventory query
    By EDEd in forum Queries
    Replies: 1
    Last Post: 10-08-2010, 11:54 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