W
WSF
Access97
I am trying to set a ComboBox Row Source using VBA and cannot work out
the correct syntax.
I wish to list two columns in the combo box thus:
The source is a table called tblStock which holds among it the
appropriate fields
PartNo [these are unique part numbers]
Description [descriptive text of the PartNo]
Group [these determine the Brand of the PartNo e.g. Honda, Ford, Nissan
etc]
Type [these categorise the PartNo's e.g. Accessory, Panel, Electrical etc]
The Group and Type are determined by Variables taken from option groups
selected on the form prior to entering the combo box
I wish the list all PartNo and Description sorted ascending by PartNo
where the Group and Type meet criteria determined by the aforementioned
selected options.
I have tried:
Dim StockGroup As String, StockType As String
Select Case Me!optGroup
Case 1
StockGroup = "Honda"
Case 2
StockGroup = "Ford"
End Select
Select Case Me!optType
Case 1
StockType = "Accessory"
Case 2
StockType = "Panel"
End Select
Me!lstPartNo.RowSource = "SELECT STOCK.PartNo, STOCK.Description From
Stock WHERE ((Stock.Group) = [StockGroup]) And ((Stock.Type) =
[StockType])) ORDER BY STOCK.PartNo;"
Me!lstPartNo.Requery
Nothing appears in the ComboBox
Any help gratefully appreciated
WSF
I am trying to set a ComboBox Row Source using VBA and cannot work out
the correct syntax.
I wish to list two columns in the combo box thus:
The source is a table called tblStock which holds among it the
appropriate fields
PartNo [these are unique part numbers]
Description [descriptive text of the PartNo]
Group [these determine the Brand of the PartNo e.g. Honda, Ford, Nissan
etc]
Type [these categorise the PartNo's e.g. Accessory, Panel, Electrical etc]
The Group and Type are determined by Variables taken from option groups
selected on the form prior to entering the combo box
I wish the list all PartNo and Description sorted ascending by PartNo
where the Group and Type meet criteria determined by the aforementioned
selected options.
I have tried:
Dim StockGroup As String, StockType As String
Select Case Me!optGroup
Case 1
StockGroup = "Honda"
Case 2
StockGroup = "Ford"
End Select
Select Case Me!optType
Case 1
StockType = "Accessory"
Case 2
StockType = "Panel"
End Select
Me!lstPartNo.RowSource = "SELECT STOCK.PartNo, STOCK.Description From
Stock WHERE ((Stock.Group) = [StockGroup]) And ((Stock.Type) =
[StockType])) ORDER BY STOCK.PartNo;"
Me!lstPartNo.Requery
Nothing appears in the ComboBox
Any help gratefully appreciated
WSF