Trevor G
Registered User.
- Local time
- Today, 19:06
- Joined
- Oct 1, 2009
- Messages
- 2,368
I am receiving an Error Number 3075 when I run a filter on a form from several combo boxes (each field has text entires only)and the results are filtered correctly in the subform, but when I click the Export to Excel it gives me the runtime error. and the message says Syntax Error missing operator:
My code is indicated below:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ws As Excel.Application
Dim strSQL As String
Dim strParam As String
Dim blnFlag As Boolean
Dim i As Long
strSQL = "SELECT *INTO ztblSearchEngine FROM qrySearchFacility"
strParam = " WHERE "
If Not IsNull(Me.cboUWYear.Value) Then
strParam = strParam & "[Underwriting Year]='" & Me.cboUWYear.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboBroker.Value) Then
strParam = strParam & "[Broker]='" & Me.cboBroker.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboDomicile.Value) Then
strParam = strParam & "[Insured Domicile]='" & Me.cboDomicile.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboInsured.Value) Then
strParam = strParam & "[Insured Name]='" & Me.cboInsured.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboPolicy.Value) Then
strParam = strParam & "[Policy Reference]='" & Me.cboPolicy.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboTeam.Value) Then
strParam = strParam & "[Team]='" & Me.cboTeam.Value & "'"
blnFlag = True
End If
If blnFlag = True Then
strSQL = strSQL & strParam
End If
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.OutputTo acOutputTable, "ztblSearchEngine", "Excel97-Excel2003Workbook(*.xls)", CurrentProject.Path & "\Search.xls", False, "", 0, acExportQualityPrint
Dim xlapp As Excel.Application
Set xlapp = CreateObject("excel.application")
With xlapp
.Workbooks.Open CurrentProject.Path & "\search.xls"
.Columns("A:AF").Columns.AutoFit
.Visible = True
End With
My code is indicated below:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ws As Excel.Application
Dim strSQL As String
Dim strParam As String
Dim blnFlag As Boolean
Dim i As Long
strSQL = "SELECT *INTO ztblSearchEngine FROM qrySearchFacility"
strParam = " WHERE "
If Not IsNull(Me.cboUWYear.Value) Then
strParam = strParam & "[Underwriting Year]='" & Me.cboUWYear.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboBroker.Value) Then
strParam = strParam & "[Broker]='" & Me.cboBroker.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboDomicile.Value) Then
strParam = strParam & "[Insured Domicile]='" & Me.cboDomicile.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboInsured.Value) Then
strParam = strParam & "[Insured Name]='" & Me.cboInsured.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboPolicy.Value) Then
strParam = strParam & "[Policy Reference]='" & Me.cboPolicy.Value & "'"
blnFlag = True
End If
If Not IsNull(Me.cboTeam.Value) Then
strParam = strParam & "[Team]='" & Me.cboTeam.Value & "'"
blnFlag = True
End If
If blnFlag = True Then
strSQL = strSQL & strParam
End If
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
DoCmd.OutputTo acOutputTable, "ztblSearchEngine", "Excel97-Excel2003Workbook(*.xls)", CurrentProject.Path & "\Search.xls", False, "", 0, acExportQualityPrint
Dim xlapp As Excel.Application
Set xlapp = CreateObject("excel.application")
With xlapp
.Workbooks.Open CurrentProject.Path & "\search.xls"
.Columns("A:AF").Columns.AutoFit
.Visible = True
End With