I received help from this site yesterday, but I am still having problems with the code. I will try and describe my situation. I have two tables, Dealer Info and Call Log. In my form I have a combo box that should provide a list of the dealers in the Dealer Info table. When I select the dealer name from the combo box I want it to grab the dealer information from the Dealer Info table, which is fax, phone, and technical communicator, and display it on the form. I want it to also store the dealer name in the call log table, but I only want the fax, phone, and tech comm viewed on the form for that record. The problem I am having with the code is it is changing information in the dealer info table and in the call log table. In the call log table it is adding the dealer name to the appropriate record, but it is also changing the dealer name of the first record of the table or it may even add a number in place of the name.
Can you help?
here is the code for the combo box:
Private Sub cmbDealer_AfterUpdate()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Dealer Info")
rst.Index = "Dealer Name"
rst.Seek "=", Me!cmbDealer
If rst.NoMatch Then
MsgBox "Dealer not found!"
Else
Me!Dealer = rst![Dealer Name]
Me!fax = rst![Fax Number]
Me!tc = rst![Technical Communicator]
Me!phone = rst![Phone Number]
End If
End Sub
Can you help?
here is the code for the combo box:
Private Sub cmbDealer_AfterUpdate()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Dealer Info")
rst.Index = "Dealer Name"
rst.Seek "=", Me!cmbDealer
If rst.NoMatch Then
MsgBox "Dealer not found!"
Else
Me!Dealer = rst![Dealer Name]
Me!fax = rst![Fax Number]
Me!tc = rst![Technical Communicator]
Me!phone = rst![Phone Number]
End If
End Sub