T
Tony Girgenti
In the attached function coding the "Set" line works ok and doesn't return
any errors. Yet when it gets to the "DoCmd" it gives "Error 3075 (Syntax
error in query expression".
If it works for the "OpenRecordSet", why won't it work for the "OpenReport"
?
Since, it basically uses the same statement.
Any help provided would be greatly appreciated.
Thanks,
Tony
Function CustQuery()
On Error GoTo CustQueryError
CustQuery = 1
CusQry = "SELECT DISTINCT cust.*, sa_lin.item_no AS itemnumber " & _
"FROM (cust " & _
"INNER JOIN sa_hdr " & _
"ON cust.nbr = sa_hdr.cust_no) " & _
"INNER JOIN sa_lin " & _
"ON sa_hdr.ticket_no = sa_lin.hdr_ticket_no " & _
"WHERE sa_lin.item_no BETWEEN '" & StartItem & "' AND '" &
EndItem & "' " & _
"AND sa_hdr.post_dat BETWEEN '" & StartDate & "' AND '" &
EndDate & "' " & _
"AND cust.zip_cod BETWEEN '" & StartZipCode & "' AND '" &
EndZipCode & "' " & _
"AND (cust.cat = '" & CustCat & "' OR '" & CustCat & "' =
'ZZZZZ') " & _
"ORDER BY cust.nbr;"
Set Cusrs = dbs.OpenRecordset(CusQry, dbOpenSnapshot)
Set StrQry = "sa_lin.item_no = '" & StartItem & "';"
If (Cusrs.RecordCount = 0) Then
CustQuery = 0
Else
DoCmd.OpenReport "cust", acPreview, , StrQry
End If
Exit Function
CustQueryError:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")", vbCritical
CustQuery = 0
End Function
any errors. Yet when it gets to the "DoCmd" it gives "Error 3075 (Syntax
error in query expression".
If it works for the "OpenRecordSet", why won't it work for the "OpenReport"
?
Since, it basically uses the same statement.
Any help provided would be greatly appreciated.
Thanks,
Tony
Function CustQuery()
On Error GoTo CustQueryError
CustQuery = 1
CusQry = "SELECT DISTINCT cust.*, sa_lin.item_no AS itemnumber " & _
"FROM (cust " & _
"INNER JOIN sa_hdr " & _
"ON cust.nbr = sa_hdr.cust_no) " & _
"INNER JOIN sa_lin " & _
"ON sa_hdr.ticket_no = sa_lin.hdr_ticket_no " & _
"WHERE sa_lin.item_no BETWEEN '" & StartItem & "' AND '" &
EndItem & "' " & _
"AND sa_hdr.post_dat BETWEEN '" & StartDate & "' AND '" &
EndDate & "' " & _
"AND cust.zip_cod BETWEEN '" & StartZipCode & "' AND '" &
EndZipCode & "' " & _
"AND (cust.cat = '" & CustCat & "' OR '" & CustCat & "' =
'ZZZZZ') " & _
"ORDER BY cust.nbr;"
Set Cusrs = dbs.OpenRecordset(CusQry, dbOpenSnapshot)
Set StrQry = "sa_lin.item_no = '" & StartItem & "';"
If (Cusrs.RecordCount = 0) Then
CustQuery = 0
Else
DoCmd.OpenReport "cust", acPreview, , StrQry
End If
Exit Function
CustQueryError:
MsgBox "Error " & Err.Number & " (" & Err.Description & ")", vbCritical
CustQuery = 0
End Function