Results 1 to 9 of 9
  1. #1
    Tuuslar is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2022
    Posts
    4

    choseing table as datasource based on combobox entry

    Hi,
    Want to build products data (price) searching form. I have many different suppliers and don't want to but all prices into one big "pricelist" where will be more then about 1M rows, but keep pricelists in different tables.


    So from first combo I want to chose supplier and next combo should search in this particular supplier pricelist/table. I managed to get list of all tables in my database to combobox. But can't figure out how "link" particular supplier pricelist into second combo.

    thanks in advance

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    How would you keep such a list current? How long would the price you record be the "effective price"? Prices change for many reasons. Where do get these prices?

    May be you could tell us more of your requirement and environment.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I have many different suppliers and don't want to but all prices into one big "pricelist" where will be more then about 1M rows, but keep pricelists in different tables.
    what do you see as the benefit of using separate tables? you'll still have 1m records

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    You might want to look up "Cascading combo boxes":https://www.google.com/search?q=casc...hrome&ie=UTF-8

    Basically your second combo box row source needs to reference the first one where you select the supplier; then in the second combo's Enter or GotFocus event you requery it.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Tuuslar is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2022
    Posts
    4
    Quote Originally Posted by orange View Post
    How would you keep such a list current? How long would the price you record be the "effective price"? Prices change for many reasons. Where do get these prices?

    May be you could tell us more of your requirement and environment.
    Thanks for replay.
    Right now I have 15+ excel tables. It means endless open-close excels + copy/paste - to set up price quote for customers. I have sophisticated soft for accounting, but it has some cons why I would prefer to use excel type list for price lookup.
    Usually these tables will be update once per year. But time to time often. To keep them separate would enable to update them when needed or delete completelly.


    Do you believe that 1 "Products" table with supplierID column would work better then preliminary comobox sorting of different tabels for such a amount of rows?
    This may be better way for next step as I plan to collect all these search results to another form to generate offer to enduser. I don't know. Hope someone could comment.

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you haven't provided any reason for using multiple tables except you prefer to use the excel type list for price lookup. It is very difficult for databases to do things the excel way since they are not designed to work that way.

    So from first combo I want to chose supplier and next combo should search in this particular supplier pricelist/table
    very easy to do with a single table and a technique called 'cascading combos'. Not so easy with separate tables.

    Do you believe that 1 "Products" table with supplierID column would work better then preliminary comobox sorting of different tabels for such a amount of rows?
    As all responders here have said - No.

    From your brief description of your requirement, you need 3 tables

    tblProducts
    ProductPK
    ProductName
    SKU

    tblSuppliers
    SupplierPK
    SupplierName

    tblPrices
    PricePK
    SupplierFK
    ProductFK
    Price
    DateFrom
    minOrderQty???
    BoxQty?????

    last 2 fields might go into a separate table if needed

    you might need a separate table for Supplier SKU's

    tblSupplierSKU
    SKUPK
    SupplierFK
    ProductFK
    SupplierSKU

    You might need more fields/tables to store information such as delivery times/costs etc

    With regards copy/paste you would use a query to import and append or update data instead

  7. #7
    Tuuslar is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2022
    Posts
    4
    Quote Originally Posted by Ajax View Post
    you haven't provided any reason for using multiple tables except you prefer to use the excel type list for price lookup. It is very difficult for databases to do things the excel way since they are not designed to work that way.

    very easy to do with a single table and a technique called 'cascading combos'. Not so easy with separate tables.

    As all responders here have said - No.

    From your brief description of your requirement, you need 3 tables

    tblProducts
    ProductPK
    ProductName
    SKU

    tblSuppliers
    SupplierPK
    SupplierName

    tblPrices
    PricePK
    SupplierFK
    ProductFK
    Price
    DateFrom
    minOrderQty???
    BoxQty?????

    last 2 fields might go into a separate table if needed

    you might need a separate table for Supplier SKU's

    tblSupplierSKU
    SKUPK
    SupplierFK
    ProductFK
    SupplierSKU

    You might need more fields/tables to store information such as delivery times/costs etc

    With regards copy/paste you would use a query to import and append or update data instead
    Thank you for makeing clrear! Will start to think "database way". I'm wondering why product names and price needs to be kept separate? ProductPK - I suppose you mean product code, but FK?

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    PK is Primary Key - a field that is indexed and has no duplicates and uniquely identifies the record - and is identified as such. For efficiency this is usually a number but can be text. Also usually the autonumber is used so it populates automatically. You might use your product code, but it is generally better not to - you have additional work if it needs to change. The efficiency come from data sizes - a long number is 4 bytes, text is 2 bytes per character plus another 2 bytes. So an 8 character code will be 18 bytes - 4.5 times larger than an 8 digit number.

    FK is Foreign Key - used in the child table, this field is indexed, but duplicates are allowed and contains the PK value of the parent record. As with the PK this value is stored in the field and in the index. So say you have 100 parent records and each has 10 child records (i.e. a total of 1000 child records). So your db requires for a long number index 8+8000 bytes. for text it requires 36+36000 bytes, of disk space.

    Further when an index is interrogated, the OS can only read 4096 bytes at a time. If the index is numeric, it can pick up 1024 index values, if text it can only pick up 227 index values. Indexing algorithms are pretty smart but you can see you have a built in inefficiency with text.

    Why index? performance again. If a field is not indexed, the db has to scan every record looking for a match - which clearly will take a lot longer. See this link about indexing
    https://www.access-programmers.co.uk.../#post-1516326

    Note when searching for values using Like, try to avoid the initial * - using it prevents the use of indexing. To avoid, as much as possible ensure your fields are set up in a way that you don't need it (e.g. store lastname/firstname in separate fields, if you have codes to indicate more than one thing, break it down to the separate elements). If you don't know what I'm talking about, don't worry, you'll come to understand soon enough

    My other tip for you is to google/bing 'database normalisation'

    I'm wondering why product names and price needs to be kept separate?
    you may not, but prices change over time and you may want to know what the price was a year ago compared with now - so you have multiple prices per product. Also means you can add future prices in now with an effective date in the future which can help balance your workload.

  9. #9
    Tuuslar is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2022
    Posts
    4
    Thank you. This all make sense.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-04-2015, 09:48 AM
  2. Replies: 1
    Last Post: 05-24-2014, 09:08 AM
  3. Combobox datasource SQL question
    By hascons in forum Queries
    Replies: 3
    Last Post: 04-17-2014, 01:32 PM
  4. Replies: 10
    Last Post: 07-25-2013, 07:36 AM
  5. Replies: 3
    Last Post: 09-19-2012, 11:40 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