Results 1 to 9 of 9
  1. #1
    PubCrawl is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    5

    Help with indexes


    Hi all, I need to get the "Quantity" field in this table to show the count of the hardware (HWID) only if it occurs mulitple times in a particular computer (ComID).


    Datasheet view:
    Click image for larger version. 

Name:	Capture.jpg 
Views:	25 
Size:	108.3 KB 
ID:	43685

    I can't seem to get any result but zero.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	24 
Size:	30.4 KB 
ID:	43684


    The relationships need to look like this:

    Click image for larger version. 

Name:	Capture.jpg 
Views:	25 
Size:	57.2 KB 
ID:	43686

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    indexing has nothing to do with this and you should not be storing this sort of calculated value in a table - use an aggregate query

    Code:
    SELECT ComID, HWID, Count(HWID) as Quantity
    FROM [Computer Parts]
    GROUP BY ComID, HWID

  3. #3
    PubCrawl is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    5
    Thanks for that, others told it did have something to do with indexing.

    However, this is part of a uni assignment which states what tables and queries we need to make. Further, when I do put that code in, it returns all Quantities of 1. Here's some more context to the assignment, if it helps, and you can bothered. I've been stuck on this part for a week, I've gone as far ahead in the assignment I can, but have hit road blocks all the way. I'm not great at this program.


    About the computer parts (ComputerParts), he wants to keep:
    · ComID: the ID number used to distinguish each PC, which comes from the Computer table (e.g.,
    1000)
    · HWID: the ID that identifies the specific brand of hardware used to build the PC (e.g., 10000)
    · Quantity: the number of the particular hardware component used in the PC (e.g., 1)
    · The combination of ComID and HWID will be unique in the table. That is, every hardware used in a
    particular computer will be recorded only once and if multiple number of the same hardware (e.g.
    RAM) is used then its recorded in the Quantity field.

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As per you more detailed description, you have stated the combination of ComID and HWID are unique so the Quantity field cannot be a calculation it is a data fact.

    You need to make a compound index on ComID and HWID .
    You can then query that data to give you a total number of different Hardware across the entire data set.
    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
    PubCrawl is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    5
    I'm so confused. I'm not even sure what a compound index is? Let alone how and where to format it? How do I get the quantity results in that table? The assignment states all of the queries we are meant to do and that one isn't one of them. For some reason the quantity is now showing nothing at all.

    Click image for larger version. 

Name:	Picture1.png 
Views:	19 
Size:	23.2 KB 
ID:	43690

    Click image for larger version. 

Name:	Picture2.png 
Views:	19 
Size:	39.2 KB 
ID:	43691

    Click image for larger version. 

Name:	Picture3.png 
Views:	19 
Size:	42.0 KB 
ID:	43692

  6. #6
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    As we have stated, the quantity in the table must be a datapoint not a calulation.

    Take a step back and lets use some sample data ;

    TableCompHardware TableComp TableHardware
    ComID HWID Qty ComID CompName HWID HWDescription
    1 1 1 1 Berts PC 1 2Gb Ram
    1 2 1 2 Harrys PC 2 Nvidia Grphx Card 1001
    1 3 1 3 Sound Card
    2 1 2
    2 2 1


    As you can see you can't calculate the qty - it a piece of fixed data, there are 2 x 2gb sticks of Ram in Harry's pc.

    You had the correct idea with the setting the primary key on the two fields ComID and HWID.

    You can use a query to add up the total amounts of hardware across the whole list of computers, but you can't magic that data out of the ether.
    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 ↓↓

  7. #7
    PubCrawl is offline Novice
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    5
    I just don't get it. Nothing shows in the quantity bit at all, whereas before it was at least saying zero. Thank you heaps anyway, between this and the rest of the assigment, I guess I'm just fried.

  8. #8
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Nothing will show up in the quantity field - it is data that needs entering, just like the computer and hardware ID's.
    Enter a number and/or set a default value of 1 as it's the minimum you would record.
    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 ↓↓

  9. #9
    CarlettoFed is online now Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2019
    Posts
    257
    Perhaps if you attach a sample file, replacing any sensitive data will make it easier for you to see how easily your problem is solved.

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

Similar Threads

  1. Table Indexes
    By Joetoben in forum Queries
    Replies: 1
    Last Post: 05-21-2015, 12:14 PM
  2. Indexes in a Table
    By FB93 in forum Access
    Replies: 2
    Last Post: 03-18-2014, 07:27 PM
  3. Too Many Indexes
    By cbrsix in forum Database Design
    Replies: 22
    Last Post: 11-07-2011, 11:12 AM
  4. Indexes limited
    By DanW in forum Access
    Replies: 6
    Last Post: 11-12-2009, 03:12 AM
  5. Table Indexes
    By AnthonyT in forum Access
    Replies: 3
    Last Post: 06-04-2009, 06: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