Hi Guys
I have a listbox that stores all Campaign types. Its a multiselect listbox so when I select multiple campaign types from the listbox then I want to add that filter in sql statement. How this can be done.
I have tried to write code but it doesn't work. ANy help will be much appreciated.
I have a listbox that stores all Campaign types. Its a multiselect listbox so when I select multiple campaign types from the listbox then I want to add that filter in sql statement. How this can be done.
I have tried to write code but it doesn't work. ANy help will be much appreciated.
Code:
Private Sub cmdExport_Click()
Dim strPath As String
Dim strName As String
Dim strFull As String
Dim intCount As Integer
Dim NewName As String
Dim strsql As String
Dim i As Integer
Dim a As String
a = ""
' Fetch multiple campaign types
For i = 0 To Me.cboType.ListCount - 1
If Me.cboType.Selected(i) = True Then
a = a & "Type=" & Me.cboType.ItemData(i) & " " & "or "
End If
Next i
' How to add multiple campaign types filter in the sql below. We will add filter in 'Type' field???"
strsql = "SELECT tbl_LM_Lead_Mas_Details.*, tbl_LM_Lead_Mas_Customer.*, tbl_LM_Lead_Ref_Campaign.Type FROM (tbl_LM_Lead_Mas_Customer INNER JOIN (tbl_LM_Lead_Mas_Details INNER JOIN tbl_LM_Lead_Ref_CustomerLead ON tbl_LM_Lead_Mas_Details.LeadId = tbl_LM_Lead_Ref_CustomerLead.Leadid) ON tbl_LM_Lead_Mas_Customer.CustomerNo = tbl_LM_Lead_Ref_CustomerLead.CustomerNo) INNER JOIN tbl_LM_Lead_Ref_Campaign ON tbl_LM_Lead_Mas_Details.CampaignId = tbl_LM_Lead_Ref_Campaign.CampaignId WHERE (((tbl_LM_Lead_Mas_Details.LeadStatusId)=1) AND ((tbl_LM_Lead_Mas_Details.AcceptedBy) Is Null));"
strName = "LM_DailyExport"
NewName = strName
strFull = CurrentProject.Path & "\" & NewName & ".txt"
DoCmd.TransferText acExportDelim, , strsql, FileName:=strFull, hasfieldnames:=False
MsgBox "Leads exported for " & Me.cboType.Column(1), vbInformation + vbOKOnly, "Export Completed"
Me.cmdExport.Visible = False
Me.cmdLeadExportClick.Visible = True
Me.cboType = ""
End Sub