Hey all! I have a quick question.....I have 2 combo boxes on a form labeled "frmInventory"...
cboRetailer
cboVendor
I also have a subform "frmInventorySubform". I have the cboboxes pull addresses etc from the retailer and vendor on the form which is great, however, I wish the user to select the retailer and vendor from the cbo boxes and the SUBFORM populate with the correct data for those matches. They should also be able to enter new data if necessary. The subform pulls from the table labeled "tblInventory".
I got some great advice earlier (see below), but I'm sorry to say I'm a beginner at VBA, so I need a little more instruction cause I just cant get it!
Thanks for your help...
--CODE GIVEN TO ME TO TRY---I CANT GET IT TO WORK!---
Dim Sql As String
Dim Ctrl As Control
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Sql = "SELECT tblCampaign.CampaignID, tblCampaign.CampaignVersion, tblCampaign.CampaignName FROM tblCampaign where "
If (Combo14 <> ""
Then
Sql = Sql & "tblCampaign.CampaignStatus IN("
Sql = Sql & """" & Combo14.Value & """" & "
" & " And "
End If
If (Combo19 <> ""
Then
Sql = Sql & "tblCampaign.ProgramName IN("
Sql = Sql & """" & Combo19.Value & """" & "
"
End If
rs.Open Sql, cnn, adOpenKeyset
MSHFlexGrid5.SetFocus
Set MSHFlexGrid5.DataSource = rs
Set rs = Nothing
Set cnn = Nothing
cboRetailer
cboVendor
I also have a subform "frmInventorySubform". I have the cboboxes pull addresses etc from the retailer and vendor on the form which is great, however, I wish the user to select the retailer and vendor from the cbo boxes and the SUBFORM populate with the correct data for those matches. They should also be able to enter new data if necessary. The subform pulls from the table labeled "tblInventory".
I got some great advice earlier (see below), but I'm sorry to say I'm a beginner at VBA, so I need a little more instruction cause I just cant get it!
Thanks for your help...
--CODE GIVEN TO ME TO TRY---I CANT GET IT TO WORK!---
Dim Sql As String
Dim Ctrl As Control
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Sql = "SELECT tblCampaign.CampaignID, tblCampaign.CampaignVersion, tblCampaign.CampaignName FROM tblCampaign where "
If (Combo14 <> ""
Sql = Sql & "tblCampaign.CampaignStatus IN("
Sql = Sql & """" & Combo14.Value & """" & "
End If
If (Combo19 <> ""
Sql = Sql & "tblCampaign.ProgramName IN("
Sql = Sql & """" & Combo19.Value & """" & "
End If
rs.Open Sql, cnn, adOpenKeyset
MSHFlexGrid5.SetFocus
Set MSHFlexGrid5.DataSource = rs
Set rs = Nothing
Set cnn = Nothing