hello, im looking to seek some help in trying to locate an error (syntax error 3075 missing operator) that comes up when I try to run a SQL string in VBA. the problem looks to be the variables I am using in the string as it runs ok if I hard code in a date. The code takes a week number from a form and converts it into the date chosen...here's the code
Any help would be greatly appreciated
Code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strValue As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryPareto")
Dim strSQL As String
Dim dates As Date
Dim weekstart As Integer
Dim Msgstart As Date
Dim weekend As Integer
Dim Msgend As Date
weekstart = Forms![frmweekno]![Text0]
Msgstart = DateAdd("ww", weekstart, DateSerial(Year(Date), 1, -5))
weekend = Forms![frmweekno]![Text7]
Msgend = DateAdd("ww", weekend, DateSerial(Year(Date), 1, 1))
strSQL = "SELECT (Count(*)) AS [Fail Count], Left([Field4],25) AS [Fail Desc], JassnrF1.field3 AS Status " & _
"FROM JassnrF1 " & _
"WHERE (((JassnrF1.DateIn) BETWEEN #" & Msgstart & "# AND #" & Msgend & "#" & _
"GROUP BY Left([Field4],25), JassnrF1.field3 " & _
"HAVING (((JassnrF1.field3) Like 'fail')) " & _
"ORDER BY (Count(*)) DESC;"
qdf.SQL = strSQL
DoCmd.OpenReport "rptParetobutton", acViewPreview
Set qdf = Nothing
Set db = Nothing
Any help would be greatly appreciated