Data Autofill

Zacharyjuniorman

New member
Local time
Today, 07:53
Joined
May 15, 2001
Messages
7
Here is my problem. I have a customer table that includes - customer id(AutoNumber), customer name, customer address, customer city, customer state, customer zip, customer phone. I want to be able select the customer name from a drop down box and have the remaining data fill in auto. I read other posts tried the code and it does not work. Please forgive me I am new at vb.

Here is the event I have on the drop down box that gets the error.Private Sub Combo17_AfterUpdate()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCustomers")
rst.Index = "CustomerName"

rst.Seek "=", Me!Combo17

If rst.NoMatch Then
MsgBox "Customer not found!"
Else
Me!CustomerName = rst![CustomerName]
Me!CustomerAddress = rst![CustomerAddress]
Me!CustomerCity = rst![CustomerCity]
Me!CustomerState = rst![CustomerState]
Me!CustomerPhone = rst![CustomerPhone]
End If
End Sub

Private Sub Combo17_BeforeUpdate(Cancel As Integer)

End Sub
 
If you want to use the Combo box navigationally (in other words diplay all the information for a particular Customer by selecting the Customer's name from a Combo Box) then the way to do it is to use the RecordsetClone property of your form.
Make the Combo Box Unbound, set it's RecordSource to something like this...

SELECT cust_no, cust_name FROM tblCustomer ORDER BY cust_no;

Make sure the bound column of the combo box is set to 1 (the column that holds the cust_no). Once that is done you reference the RecordsetClone property of the form in the cboCustomer_AfterUpdate event....

Me.RecordsetClone.FindFirst "cust_no = " _
& me.cboCustomer
Me.Bookmark = Me.RecordsetClone.Bookmark

HTH
Chris
 

Users who are viewing this thread

Back
Top Bottom