Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error expected end of statement 1

Status
Not open for further replies.

primerov

Technical User
Aug 16, 2002
160
0
0
BG
I am trying to build a function that refers to the table instead to the form. I think i should use the DLookup function, i do not know any other way.
However, i receive the error "Expected : end of statement"
Can i refer to a table at all in the function mentioned below and where might the error
be in this function ?

Public Function RemoveBefore()
Dim SqlRemoveFromOrders As String
SqlRemoveFromOrders = " DELETE DISTINCTROW orders.orderdate AS Expr1 " & _
" FROM orders " & _
" WHERE orders.orderdate < DLookUp("[CutDate]";"TblCutDate")"
CurrentDb.Execute SqlRemoveFromOrders
End Function


 
Hi,

Your syntax is slightly off with you SQL. You also should have a comma instead of a semi-colon:
Code:
SqlRemoveFromOrders = "DELETE DISTINCTROW orders.orderdate  AS Expr1  " & _
" FROM orders " & _
" WHERE orders.orderdate < [COLOR=red]"[/color] & DLookUp("[CutDate]"[COLOR=red],[/color]"TblCutDate")
HTH,
Dean
 
And what about something like this ?
SqlRemoveFromOrders = "DELETE FROM orders " & _
" WHERE orderdate<(SELECT CutDate FROM TblCutDate);"
You may need a where clause in the subquery.


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top