Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Query

Status
Not open for further replies.

shummy1

Technical User
Mar 17, 2005
22
CA
Is it possible to populate a combo box with a query and then have the chosen item in the combo box update to a record in a table?

The query pulls from the same table that the record will be save in.

ie customer name combo box is populated with a query run on the orders table where the query pulls all the customers listed.
The customer is chosen and other fields are filled in.then the record is updated to the orders table.
In this way the next time the form is opened the most current list of customers is available.

The user however must also be able to add a new customer that is not on the combo list.

I know it is a long one. Just need to knw if it is possible for now.
I have managed to get this all working in Access but I have been told that the user requires a VB front end.
Help??
 
Short answer - yes, it's possible. See ADO. You might be able to do it all with bound controls (to the database). I never use them myself. You will have to write all the database access parts - nothing is auto-magic - doh!

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Ok I will try that out. It may be a while before I get back to you as this is a "when I have time" project
 
I do this all the time, generally using AutoNumber (Identity) columns for the key. The ItemData property is useful in this regard. It allows you to store an integer value for each line item in the combo box, which you can evaluate when a selection is made.

Limitations of the ItemData property:
1. You have an autonumber value of greater than 32,768.
2. You have a key that isn't a number.

In either case, I've found that declaring an array that holds the set of keys for the list box's line items, and storing the offset of each array item in the appropriate ItemData property works fine here.

HTH

Bob
 
Hmmm. OK will try that out if I don't get anywhere with the first plan.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top