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

Query with list item from combo box 1

Status
Not open for further replies.

BasicBoy

Programmer
Feb 22, 2008
156
ZA
I need to set up a query to incorporate the listitem name from a combo box into the resultant field like in :

Query$= "Select ID, cboDeliverBy.list(Field called 'ListIndexOfCbo' of the table, which is an integer pointing to the position of the listitem), DeliverDate from MyTable ....

so that I get :

Field(0) : ID
Field(1) : "Only deliver after" which is the listitem listed in the cbo in position 'ListIndexOfCbo"
Field(2) : 20/04/2011 'the deliver date'

Thank you so much
 
Something like this ?
Code:
Query$= "Select ID,[" & cboDeliverBy(ListIndexOfCbo) & "],DeliverDate from MyTable ...."

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I am afraid this does not work.
My query now looks like this and still does not work :

S$ = "Select items.ID, ordercats.catname, items.itemname, items.itemunit, [" & cboItemStatus.List(items.itemstatus) & "], laststock, .....

Can somebody please help.
 
Why not simply JOIN MyTable with the underlaying SQL of the combo ?
In other words, what do you want to do with what ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Say I have a grid which is populated with an index which refers to a product type - say apples - and appleType = 1 and peachtype = 2... and so on.
Only the indexes are stored in the database table.
When I populate the grid, it gives me 1's and 2's etc in the type columns.
Now I need to run through the column and replace all the indexes with the fruitnames. Where there is a 2, I need to replace it with Peaches which is no. 2 on the cboFRUIT - or listindex=2 - or cboFRUIT.list(2).
I thought I might write a query where the name of the fruit is already written into the grid during the population of the grid.

Thanks
 
You don't have a tblFruit table ?[tt]
Type FruitName
1 Apple
2 Peach
...[/tt]
you simply have to join this table in your query.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That is the problem - I populate cboFruit programmatically - having only about 3, but for some larger collections I have a table for the types and that works well in the join.
 
Even if you have only 2 types, use a table instead of hardcoding values programmatically ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top