Hello Douglas.
Assuming "\/" in the Format statement = a backslash and forwardslash, i
now get a Datatype mismatch in criteria expression".
Thanks,
Tony
I believe Van had a slight typo there.
Try
Format(Me.EndDat, "\#mm\/dd\/yyyy\#")
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hello Van.
Yes it is a DateTime field. When i try your suggestion, i get:
Syntax error (missing operator) in query expression '([COMPANY NAME]
= "BLAIR HOUSE 10023" AND [SIDEMARK] = "MARGARGEL" AND PENDING
ORDERS.TIMESTAMP Between "#04d5y0496#" And "#04d5y0496#")'<<
Thanks,
Tony
message In addition to John's advice ...
Is your TIMESTAMP a DateTime Field?
If it is, you should use something like:
Format(Me.EndDat, "\#mm\dd\yyyy\#")
so that your constructed SQL becomes:
...([COMPANY NAME]="BLAIR HOUSE 10023")
AND ([SIDEMARK]="MARGAREL")
AND [PENDING ORDERS].[TIMESTAMP]
Between #04/05/2004# And #04/05/2005#)
--
HTH
Van T. Dinh
MVP (Access)
Hello.
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