
Fill Combo List using Criteria selected in another Combo List
'These codes are taken from my current project for a Computer
Reseller/Assembler which, I believe, closely resembles to what you're
trying to do.
'About the UPDATE, well, that's another story...er...subProcedure.
'rsPart recordset declaration can be included inside the subProcedure or,
as in my case, in a separate module.
Public Sub qMaker() 'procedure to populate PART ComboBox
Dim strMaker As String
On Error Resume Next
strMaker = "Select DISTINCT Part_description from Part "
Set rsPart = dbConn.Execute(strMaker)
rsPart.MoveFirst
cboQPartName.Clear
Do Until rsPart.EOF
cboQPartName.AddItem rsPart!Part_description
rsPart.MoveNext
Loop
End Sub
'*** When you select from the COMBOBOX, it will execute the ff. code ***
Private Sub cboQMaker_Click() 'procedure to populate PART TYPE ComboBox
Dim strType As String
On Error Resume Next
strType = "Select DISTINCT Part_type from Part where Part_description = " _
& "'" & cboQPartName.Text & "'"
Set rsPart = dbConn.Execute(strType)
rsPart.MoveFirst
cboQPartType.Clear
Do Until rsPart.EOF
cboQPartType.AddItem rsPart!Part_Type
rsPart.MoveNext
Loop
End Sub
Quote:
> I have 2 (data) Combo Boxes on a VB6. One lists computer component
> categories ie Hard Drives, Motherboards, Monitors etc
> The other lists the make/model of the components ie Western Digital 10gb
> Hard drive.
> They are both part of an MS Access(97) Database Table.
> What I want to do is have the second one's list limited by the category
> selected in the first. ie if the Hard Drive category is selected in the
> first, ONLY Hard Drives are listed in the second.
> How can this be achieved??
> I also want to update a Text Box with the price once the 2 have been
> selected, so any help with these would be VERY much appreciated.
> Cheers
--
Posted via CNET Help.com
http://www.help.com/