Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    Question Unanswered: Dynamic field based on what is entered in another field

    I have a form that has two combo boxes Name and Model. When these two have been selected, click a button that adds the value of the two combo boxes into a table. However, linked with each combination is a price that I would like to have automatically appear on the table and not on the form after the two choices have been made. How do I do that? The price is in a table with the name and model.
    Last edited by beanhead0321; 07-19-11 at 23:50.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 15
    Provided that the combination Name + Model is a unique identifier for the source table, you could use:
        Dim strSQL As String
        strSQL = "INSERT INTO <DestinationTable> ( Name, Model, Price ) " & _
                 "SELECT Name, Model, Price " & _
                 "FROM <SourceTable> " & _
                 "WHERE <SourceTable>.Name = '" & Me.<ComboName>.Value & "' AND " & _
                       "<SourceTable>.Model = '" & Me.<ComboModel>.Value & "';"
        CurrentDb.Execute strSQL, dbFailOnError
    The elements between brackets (<>) must be replaced by the actual names. If the columns containing the Name and the Model in the combos are not the bound columns of the combos, you have to replace Me.Combo.Value with Me.Combo.Column(x) where x is the index of the proper column (the index of the first column of a combo is 0 (zero)).
    Have a nice day!

Tags for this Thread

Posting Permissions

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