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

combo box in db grid

Status
Not open for further replies.

Zamm

Programmer
Sep 22, 2001
15
0
0
PH
hi guys!

i'm working in a sales data entry. i have 3 access tables.
Sales, SalesDetails and Products tables. SalesDetails and Products tables have ProductID field. I have a master/detail form, in the detail section (i'm using db grid), i want to have a combo box that will look up the products table. how can i do it?

your help will be appreciated.


Zamm
 
Assumming your grid id bound to a data control you would follow the following basic steps,

1. You will need to fill the combo box with the values that you want. This may need to be done manually.

2. Then when an item is selected (combo1_click event) you would build an SQL statement incorporating the selected value. Assign this SQL to the .recordsource property of your data control and refresh your data control.

3. Then reset the .datasource property of your grid to the data control and refresh the grid.

If your tools are different then provide more details and we will have another look. Thanks and Good Luck!

zemp
 
If I am reading this right you also may be able to use a Data ComboBox with row source set to the ADODC you are using and the list field in the Data ComboBox to look at the column you want.
 
zemp,

thanks for ur reply.

i'm using vb6 db grid. i have 1 adodc control and i'm using shape..append statement in my adodc's recordsource. vb6 help says that u can dropdown a combo box, list box or a grid, by setting the column's button property to true and the buttonclicked event will be fired. It says that the code to dropdown the combobox should be placed in the buttonclicked event. how can i achieve this? is there other solution to my problem?

i need ur help.

zamm
 
Don't use a combo box, use a list box.
You still have to add code to the click event to fill the listbox with data, position it and make it visible to the user, capture user input from it, setting the grid cell value to the select item, and then hide the list afterwards. [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
If you are going to use a combo box set its .style property to 2 - Dropdownlist. Thanks and Good Luck!

zemp
 
zamm:

Do you need the combo in order to look up a record for the master and also set the source for the recordset that the grid is bound to?

Or just to look up data from another table for an entry into a particular cell in the details grid? [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
CCLINT:

sorry i'm out for few days.

i need the combo in order to look up a record for the master and also set the source for the recordset that the grid is bound to.

zamm


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top