PDA

Click to See Complete Forum and Search --> : selecting data from a database


bernardatherton
Jul 12th, 2000, 03:00 PM
I have an access database containg customer name, number and address.

When I enter the name PRICE, I want the code to search the database, offer me all the PRICEs so I can see if I'm entering a new customer or an existing customer. If its an existing customer I want to be able to then select that customer from the list an use the existing address and customer name to populate my new entry.

Any help out there?

Thanks

Bern

wick77
Jul 12th, 2000, 03:22 PM
Are you using VB, if you are here's some help, otherwise I can't help you,

Use a textbox to enter the cutomers name, have a data bound listbox with a Data control bound to it and three textboxes to store the data with a Data control bound to them, then use the following code:

Data1.Recordsource = "SELECT CustomerName, Number, Address FROM CustomersTable WHERE CustomerName = '" & Text1.Text & "'"

Make sure your listbox listfield is set to CustomerName. Then in the Click event of the listbox use the following code:

Data2.Recordset.FindFirst "CustomerName = '" & DBList.Text & "'"

This will fill your text boxes with the information you selected.