Hi Sophie, I've been messing around with the query and the vb in the form, and just now I've gotten to the point where I have some hope. I went and deleted all the sql from the query so its basically just a blank saved query now. This is the VB code
-
Private Sub btnRun_Click()
-
-
Dim queryis As DAO.QueryDef
-
Dim db As DAO.Database
-
Dim sign As String
-
Dim del As Date
-
Dim pickup As Date
-
Dim strCriteria As String
-
Dim strSQL As String
-
-
-
Set db = CurrentDb()
-
Set queryis = db.QueryDefs("Delivery")
-
-
del = Me.DelDate
-
-
If Me.Combo8.Value = "before" Then
-
sign = "< "
-
strCriteria = strCriteria & sign & del
-
strSQL = "SELECT * FROM Orders " & _
-
"WHERE [Delivery Date] = " & strCriteria & ";"
-
End If
-
-
queryis.SQL = strSQL
-
DoCmd.OpenQuery "Delivery"
-
-
End Sub
-
I only have the one if statement, so its only for orders before myDate. But the problem I'm having with this is when I run this I get an error that says
Syntax error(missing operator) in query expression '[Delivery Date] = <8/1/2007'
Yet If I type <8/1/07 in the criteria of the query under delivery date everything works fine. What am I doing wrong?
Thanks for the help.