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

Data sources for DB grid

Status
Not open for further replies.

afryer

Programmer
Mar 9, 2004
207
GB
All,

I have a DB grid control and I need to be able to link it to two separate combo boxes. I have managed to get one linked, but I cannot link multiple combos to the same grid. To help clarify the problem somewhat, here is an example of what it does:

The application is a car sales database. The first combo box contains models that extras are to be displayed for and the second contains the category of extras for that model.

For example:

Combo 1 : Ford Fiesta Finesse
Combo 2 : Internal Extras

When both combos are selected I need to be able to display the extras for that particular make of car and Internal Extras, so the data grid should display things such as ait conditioning, furry dice etc.

If I connect the data grid to either of the combo boxes then it works fine. I just need to know a way of connecting it to both of them!

Thanks


Andrew
 
I think you should do this one of 2 ways

1: have 2 grids and maybe make the 2nd one visible only when something is selected from the 2nd combo

2: Don't display anything in the grid until things have been picked from both combos, then do one query, which may be joined depending on your db structure.

lou

 
Its not clear from your post where the data is. That you are using TDBGrid, presumably there are datasets.

If you have (or could have) a dataset with all possible extras in it, which is displayed by your TDBGrid, in the OnCloseUp event of the combos set the filter property of the extras dataset. e.g.

Extras.Filter:='Model='''+ModelCombo.Text+''' OR Model=''Internal extras''';

Have fun
Simon



 
I assume that the data is in two separate tables, what about a using one as a look-up table? or as a master-detail relation ship?

Regards

Steven van Els
SAvanEls@cq-link.sr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top