Results 1 to 13 of 13
  1. #1
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6

    Counting objects in a query.

    Hey guys. Thanks for taking the time to read this. I'm new to Access so I may say things I know nothing about. I have a situation where I have a production line. Each station has three motors and each motor has to have three cables. Each one of the three can be different types. What I would like to do is sum up the quantities of each type of cable for all entries. Sounds simple enough but it still keeps baffling me. Please take a look at my screen shot. Thanks Click image for larger version. 

Name:	Dtable Screenshot.png 
Views:	21 
Size:	34.9 KB 
ID:	28647

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349

    You should have another table called PanelDataMotors as a child table to PanelData. Then in the child data you would have a field for MotorNumberID (primary key for table), PanelDataID (primary key value in tblPanelData), MotorNumber and MotorType. Then it would be easy as pie to get a count. Also I see your table view has a combo box - please review - http://access.mvps.org/access/lookupfields.htm. And if you have spaces in your field names, remove them, no special characters either.

  3. #3
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6
    Thanks JWhite. I'll give this a try.

  4. #4
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    You probably should have another table for motor types, tblMotorTypes (MotorTypeID, MotorType), then in tblPanelDataMotors, have MotorTypeID instead of MotorType.

  5. #5
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6
    So what your saying is I need to make another table but still link the field to the entry form. Hence the child data table.

  6. #6
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Yes, but instead of linking (storing) the actual value, you will save the Primary Key of the selected MotorType in tbl PanelDataMotors. Then in your form you would have a combobox for MotorType (cboMotorTypes) with fields MotorTypeID and MotorType. This will allow you to easily add more motor types in the future without altering any code or table design.

  7. #7
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6
    Quote Originally Posted by jwhite View Post
    Yes, but instead of linking (storing) the actual value, you will save the Primary Key of the selected MotorType in tbl PanelDataMotors. Then in your form you would have a combobox for MotorType (cboMotorTypes) with fields MotorTypeID and MotorType. This will allow you to easily add more motor types in the future without altering any code or table design.
    You lost me with this one. You say "with fields MotorTypeID and MotorType." I am possibly going to have a maximum of 8 motors per station. Then I would choose the motor type cable. I get the combobox for the type but you lost me on the motor type id. Here's a screenshot of the tables.Click image for larger version. 

Name:	motorsdbase.jpg 
Views:	14 
Size:	164.6 KB 
ID:	28660

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Nemo,

    Do you have a clear statement of requirements that you can share with users? As jwhite has advised, you appear to have a data structure issue. Your tables are not normalized, and in order to determine the required relationships, readers need to better understand your business and processes.

    Here are some links to data base planning and design info.

    Good luck.

  9. #9
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Instead of MotorType in PanelDataMotors, you would have MotorTypeID - FK to the selected record in MotorTypes. You have another repeating group of fields in [Panel Data Table] for Port(n) - these should be in another table as well. It might would be a a pain, but I would correct the naming of your objects now before going further - no spaces in object names and use industry-standard prefixes - review: https://ss64.com/access/syntax-naming-variables.html

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Nemo,

    If you marked this thread solved, could you show readers your solution? It may help someone else who has/had similar issue.

  11. #11
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6

    Lightbulb

    Quote Originally Posted by orange View Post
    Nemo,

    Do you have a clear statement of requirements that you can share with users? As jwhite has advised, you appear to have a data structure issue. Your tables are not normalized, and in order to determine the required relationships, readers need to better understand your business and processes.

    Here are some links to data base planning and design info.

    Good luck.
    This application is used for keeping track of how many different cables I use in an automotive production floor. What I'm trying to do is create a simple database that keeps track of a how many different types of cables I use to connect to a motor for a linear motor drive system. For example: I have 10 stations on one body weld line. Each station has a control Panel with an ID. Each station has three motors or four. For this example we'll keep it to three. Each motor needs a cable. That cable length can vary depending on the distance of the control panel to the motor. Also the type of cable can be either a static type or a high flex type. What I would like my database is to keep track of each style of cable for each station and give me a total of each style of cable based on length and type. Again, I'm learning as I go and I have a lot of going to do.

  12. #12
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Good stuff.

    Here is what I gleaned from your description.

    Your basic business is keeping track of how many different cables I use in an automotive production floor

    Factors:
    types of cables
    connect to a motor
    10 stations
    body weld line
    Each station has a control Panel
    Each station has three(or four) motors .
    Each motor needs a cable.
    cable length varies with the distance of the control panel to the motor
    type of cable can be either a static type or a high flex type
    style of cable for each station

    Goal/objective:
    produce total of each style of cable based on length and type

    Most readers are not in the same "business" as you, so we have some trouble understanding how these things/factors relate to one another.

    Readers will advise you to write a clear description of your business in plain English. Review/research table design and normalization; then build a draft model of your tables and relationships; test your model with sample data and what if scenarios.
    Adjust your model as necessary. When all is working on paper, then design your database using your model as a blueprint.

    Good luck.

  13. #13
    Nemo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2017
    Posts
    6
    Finally. I was finally able to figure out what to do when using combo boxes for selections. The rule is NOT to use a combo box in the main storage table. I created a lookup table to pick from and then that value is placed into the main table as text without it being a combo box selection. Once I developed "lookup" tables I was then able to create queries that added up quantities using simple summation formulas. The lookup tables also allowed me to add or delete selections without affecting other components of the main data table. Thanks to all who have helped me with this issue. Live and learn but mostly learn.

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

Similar Threads

  1. Where are the DDL of the Query Objects stored?
    By violeta_barajas in forum Access
    Replies: 5
    Last Post: 01-20-2017, 07:13 PM
  2. Query and Counting
    By johnberman in forum Queries
    Replies: 4
    Last Post: 11-08-2013, 04:36 AM
  3. Query for 2 Objects
    By mimireyes in forum Queries
    Replies: 3
    Last Post: 11-13-2012, 10:48 PM
  4. Counting in Query
    By EdwinLawrence in forum Queries
    Replies: 3
    Last Post: 03-05-2012, 12:21 PM
  5. query objects in VB6
    By genesis in forum Access
    Replies: 1
    Last Post: 07-10-2009, 02:16 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