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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting combo box to a command

Status
Not open for further replies.

toon10

Programmer
Mar 26, 2004
303
DE
HI

I have a VB 6 form, which has a combo box to select an order number and a few order fields. The idea being that I’d like to drop down the combo box, a list of order numbers will appear (from a table called order) and then when a number is selected, the order fields on the form automatically display the corresponding information for that order. I want to be able to change this data to. For example, I want to select order number “PO004” from the combo box. The order customer name and order description fields should be displayed for that order and I may need to change the description and have it saved to the database.

The data is in a SQL database and I have created a data environment and a command, which returns the relevant information. The combo box data source is set to the data environment. The combo box data member is set to the command but for some reason, when I run the program, only one order number appears in the combo box and it doesn’t list the other orders when I drop down. Any ideas would be gratefully recieved!

Thanks
Andrew
 
Hmmmm...are u using a Combo or a DataCombo(datacombo you have to specify two "data sources", second, i think that the controls should be bound not only to the Data environment, but alss to "each other"


Try creating a new project with the Project Wizard, select dat project, fill in and select all the appropriate stuff and choose it to be a "Master/Detail" form, and also choose the option where it created the project file with code. In here you should find your solution, cause it's bound to a datasource and it update the "detail" when you change records, etc

Hope this helps

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Thanks for that.

I have created a data project and I have the relevant information which I can update. I'm using a normal combo box which still doesn't seem to work though. At the minute, I have to keep skipping next through the recordset to get to the relevant record instead of selecting it via the combo box and it going straight there. I have enough to go on now though so I'll try a few more things.

Thanks again
Andrew
 
K

You can also try the following, but u will have to adjust it as I don't normally work with Data Environment and Bound controls

I'm sure u can pass the recordsource object a SQL string that can look like this

rs.open "Select * from TableName WHERE (FieldName = '" & cboCombo1.text & "')"

set Grid1.Datasource = rs

Like I said, this might not be the propper way to do it, but concidder it Phseudo Code!!

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top