T
Tony Girgenti
Hello.
Using Access 2003 on WIN XPpro.
Why am i getting this error when executing a report:
Any help would be greatly appreciated.
Here is my coding:
=============================================================================
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim stDocName As String
Dim strWhere As String
Dim strWhere2 As String
Dim lngLen As Long
UpdateTempStatus
stDocName = "CHF STATUS 3"
strWhere = " "
If Not IsNull(Forms![CHF - WIP]![Combo0]) Then
strWhere = "[COMPANY NAME] = """ & Forms![CHF - WIP]![Combo0] & """ AND "
End If
If Not IsNull(Forms![CHF - WIP]![Combo8]) Then
strWhere = strWhere & "[SIDEMARK] = """ & Forms![CHF - WIP]![Combo8] & """ AND "
End If
'***********************************************
'Starting and ending DATES: tixhisthdr.postingdate is Text.
'***********************************************
If IsDate(Me.StrDat) Then
If IsDate(Me.EndDat) Then 'Both start and end
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP Between """ & Format(Me.StrDat, "yyyymmdd") & """ And """ & Format (Me.EndDat, "yyyymmdd") & """ AND "
Else 'Start, no end
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP >= """ & Format(Me.StrDat, "yyyymmdd") & """ AND "
End If
Else
If IsDate(Me.EndDat) Then 'End, no start
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP <= """ & Format(Me.EndDat, "yyyymmdd") & """ AND "
End If
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen > 0 Then
strWhere = "" & Left$(strWhere, lngLen) & vbCrLf
End If
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
If Err.Number <> 2501 Then
MsgBox Err.DESCRIPTION
End If
On Error GoTo 0
Resume Exit_Command2_Click
End Sub
Using Access 2003 on WIN XPpro.
Why am i getting this error when executing a report:
Syntax error (missing operator) in query expression '([COMPANY NAME]="BLAIR HOUSE 10023" AND [SIDEMARK]="MARGAREL" AND PENDING ORDERS.TIMESTAMP Between "20040405" And "20040405")'<<
Any help would be greatly appreciated.
Here is my coding:
=============================================================================
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim stDocName As String
Dim strWhere As String
Dim strWhere2 As String
Dim lngLen As Long
UpdateTempStatus
stDocName = "CHF STATUS 3"
strWhere = " "
If Not IsNull(Forms![CHF - WIP]![Combo0]) Then
strWhere = "[COMPANY NAME] = """ & Forms![CHF - WIP]![Combo0] & """ AND "
End If
If Not IsNull(Forms![CHF - WIP]![Combo8]) Then
strWhere = strWhere & "[SIDEMARK] = """ & Forms![CHF - WIP]![Combo8] & """ AND "
End If
'***********************************************
'Starting and ending DATES: tixhisthdr.postingdate is Text.
'***********************************************
If IsDate(Me.StrDat) Then
If IsDate(Me.EndDat) Then 'Both start and end
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP Between """ & Format(Me.StrDat, "yyyymmdd") & """ And """ & Format (Me.EndDat, "yyyymmdd") & """ AND "
Else 'Start, no end
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP >= """ & Format(Me.StrDat, "yyyymmdd") & """ AND "
End If
Else
If IsDate(Me.EndDat) Then 'End, no start
strWhere = strWhere & "PENDING ORDERS.TIMESTAMP <= """ & Format(Me.EndDat, "yyyymmdd") & """ AND "
End If
End If
lngLen = Len(strWhere) - 5 'Without trailing " AND ".
If lngLen > 0 Then
strWhere = "" & Left$(strWhere, lngLen) & vbCrLf
End If
DoCmd.OpenReport stDocName, acViewPreview, , strWhere
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
If Err.Number <> 2501 Then
MsgBox Err.DESCRIPTION
End If
On Error GoTo 0
Resume Exit_Command2_Click
End Sub