problems with vb code (1 Viewer)

Purdue22

Registered User.
Local time
Today, 15:42
Joined
May 11, 2001
Messages
25
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 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
 

kaspi

Registered User.
Local time
Today, 15:42
Joined
Nov 22, 2000
Messages
60
Hi Purdue
It seems to me that you should check the sources of your controls on the form.
I would suggest that you use unbound controls or even levels to display the info you want to display and handle the inserts into the table seperatly.
The info display could look like
me.label_1.caption = rst![Dealer Name] etc
For the inserts you open another recordset (Call log) and insert into that second recordset.
It that way you have much more control what is going on.
Kaspi
 

Users who are viewing this thread

Top Bottom