If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Lookup Field Based on another Lookup Field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-19-11, 21:26
beanhead0321 beanhead0321 is offline
Registered User
 
Join Date: Jul 2011
Posts: 7
Question 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 22:50.
Reply With Quote
  #2 (permalink)  
Old 07-20-11, 04:49
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
Provided that the combination Name + Model is a unique identifier for the source table, you could use:
Code:
    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!
Reply With Quote
Reply

Tags
combo box, look up, query, table

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On