Results 1 to 5 of 5
  1. #1
    Onyx is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    3

    drop down that auto populates row

    I have a table called products but i want to be able to have an order form that has a drop down list of all the products and once selected will add the product and other colums such as unit price etc. How do I do that

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,127
    Create a form based on that table.
    Add a combobox with a row source equal to the product field
    Then add code in the after update event to append a new record with that product and any other fields as appropraite

    The form will need to be opened in 'ADD new record mode.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    I don't think the code needs to append record. Assuming form is bound to OrderDetails table, entry into any bound control such as the combobox will accomplish creating a new record when positioned on New Record row. Code in the combobox AfterUpdate would populate other fields with data from combobox columns. Reference columns by index. Index begins with 0 so if the price is in third column, its index is 2, example:

    Me!UnitPrice = Me.cbxProduct.Column(2)

    Saving any other data describing the product is likely unnecessary duplication.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Onyx is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    3
    I sort of get the idea however what i have is an order form and a orderdetails table i have added the orderdetails table as a sub-table within my order form. The order form will have my clients details and the sub-table the items they order. the table orderdetails has the following fields customer (relationship to customer table), product (relationship to product table), unit price, markup and price. The field called product is a lookup data type. What i need help with is that if i click on the lookup within the sub-table lets say on the product Milk i would need the unit price, markup and price fields to then get the info from the products table

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Tables are not correctly related. The Orders form should have CustomerID, OrderDetails should not have customer info, should have OrderID as foreign key.

    Cannot have the required code behind a table, must be a form. The OrderDetails needs to be a form installed as subform on Orders.

    Saving UnitPrice and Markup is reasonable because those can change over time. Price, however, is calculated from UnitPrice and Markup and should be calculated when needed, not saved.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 25
    Last Post: 11-17-2023, 08:53 AM
  2. Replies: 7
    Last Post: 04-03-2017, 08:09 AM
  3. Search Box that auto-populates
    By LukeJ Innov in forum Forms
    Replies: 3
    Last Post: 07-18-2013, 03:02 AM
  4. Replies: 1
    Last Post: 05-27-2013, 09:46 PM
  5. Replies: 3
    Last Post: 11-09-2011, 03:43 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