Auto Fill

G

Guest

Hello, I am trying to build a customer database. I am trying to have it so
that if the customer is not in the database already, you fill in the
information, but if the customer ID is already in, I would like to type in
the ID and the name/address/state/zip etc fills in automatically. Could
someone help please?

Thank you
 
J

Joseph Meehan

Steve said:
Hello, I am trying to build a customer database. I am trying to have
it so that if the customer is not in the database already, you fill
in the information, but if the customer ID is already in, I would
like to type in the ID and the name/address/state/zip etc fills in
automatically. Could someone help please?

Thank you

I believe the Northwind sample database has that feature as part of the
sample.

Note: The most important part of this is to have the table design
correct and properly normalized.
 
G

Guest

Hi Steve

You could use a standard combo serach and use the NotOnList action (if the
combo doesn't find a matching record) with something like this (you will
need to alter Combo Name, Table Name and Field Name)


Private Sub ComboSearch_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg As String

Msg = "'" & NewData & "' is not on list." & vbCr & vbCr
Msg = Msg & "Do you want to add New Record?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Have another go."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TalbleName", dbOpenDynaset)

rs.AddNew
rs![FieldName] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub


Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top