Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Location
    Kent
    Posts
    59

    Question Unanswered: Populating Fields

    Hi
    I need a little help with a db im designing, i have an orders details form which sits on the mail client form and displays the details of any given clients order when the relivent clients order is clicked in the subform above it. the Client order subform has a ProductID field which is based on a list of products in the products table.

    The Products table had the following fields: ProductID, ProductName, UnitPrice, Quanity (this is for later use when i manage to get the stock side of db working) and Discontinued Fields.

    What i need the form to be able to do is the following: when i select a product from the drop down list in the order details subform the price form the selected product populates the UnitPrice field on the order delats form.

    Can this be done? all help given greatly recieved, Ive attached a copy of the db please feel free to have a look.

    Thanks

    Icerat
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Include the following statement as the code for the After Update event of the ProductID combo box.

    Me.UnitPrice = DLookup("UnitPrice", "tbl_products", "ProductID = " & Me.ProductID)

    There are many other ways of doing the same thing.
    Rod

    fe_rod@hotmail.com

  3. #3
    Join Date
    Jul 2004
    Location
    Kent
    Posts
    59
    Hi
    I pastedwhat you said into the after update box and i get an error saying microsoft access cant find macro Me.

    any ideas

    Icerat

  4. #4
    Join Date
    Jun 2002
    Location
    Saudi Arabia / Philippines
    Posts
    126
    Ahhh! No.

    What I have given you is VBA code. Delete any macro or anything else associated with the After Update event. In design view for the subform display the Properties form and click on the Event tab. Click on the ProductID combo box to select it. Then click on the elipsis against the After Update event and choose Code Builder. After you've added the statement the module should look like the following.

    -----------------------------------

    Option Compare Database

    Private Sub ProductID_AfterUpdate()

    Me.UnitPrice = DLookup("UnitPrice", "tbl_products", "ProductID = " & Me.ProductID)


    End Sub

    --------------------------------------------

    I hope I've attached your sample db duely updated.
    Attached Files Attached Files
    Rod

    fe_rod@hotmail.com

  5. #5
    Join Date
    Jul 2004
    Location
    Kent
    Posts
    59
    Hi
    Thanks for sorting that out, thanks again

    Like i said Many Many thanks

    Icerat

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •