Hello,
I have two data comboboxes on a VB6 form "DataComboMasterPolicy" and "DataComboPurchasingGroup" after selecting the first appropriate choice with "DataComboMasterPolicy" I would like for the 2nd datacombox "DataComboPurchasingGroup" to only display the data associated with the user's selection.
The data is in an Access 2003 db.
My code for both boxes:
Private Sub DataComboMasterPolicy_Click(Area As Integer)
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\test.mdb"
rs.Open "SELECT DISTINCT MasterPolicy FROM Certificate ORDER BY MasterPolicy", cn, adOpenStatic, adLockOptimistic
Set DataComboMasterPolicy.RowSource = rs
DataComboMasterPolicy.ListField = "MasterPolicy"
End Sub
Private Sub DataComboPurchasingGroup_Click(Area As Integer)
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\test.mdb"
rs.Open "SELECT DISTINCT Code FROM qryMasterPurchasing WHERE MasterPolicy = " & DataComboMasterPolicy, cn, adOpenStatic, adLockOptimistic
Set DataComboPurchasingGroup.RowSource = rs
DataComboPurchasingGroup.ListField = "Code"
End Sub
However when I select the first combox box it doesn't appear to do what it is suppose to because I get this error:
"no value given for one or more required parameter"
I chose debug and can see the 3rd line from the bottom highlighted in yellow:
rs.Open "SELECT DISTINCT Code FROM qryMasterPurchasing WHERE MasterPolicy = " & DataComboMasterPolicy, cn, adOpenStatic, adLockOptimistic
which I attached as the "error" file, which basically tells me the line as an error yet if I over the "& DataComboMasterPolicy" section I can see it has properly memorized the selection from DataComboMasterPolicy
Could somebody help me with what I am doing wrong, or perhaps there is a tutorial somewhere?
Thank you,
John