Invalid Operation in SQL string

A

A Newbie

I have string SQL like this when I run by Query it OK but when I bring to
code it doesn't work. I don't know why. Please anybody can help me

strSQL = "SELECT Qry_SLTDTemp1.ID, Qry_SLTDTemp1.Time INTO TblSLTDTemp1"
strSQL = strSQL & " FROM Qry_SLTDTemp1"
strSQL = strSQL & " WHERE (Day(time) Between " & "1" & " And " & "5" & ")"
strSQL = strSQL & " AND Month(time)=" & "1"
Set rec = db.OpenRecordset(strSQL)

Thanks verymuch !!!
 
D

Duane Hookom

Consider not naming your fields with names of functions. Also, you are
attempting to open a recordset based on an action query (not good).

Maybe try:
strSQL = "SELECT ID, [Time] INTO TblSLTDTemp1"
strSQL = strSQL & " FROM Qry_SLTDTemp1"
strSQL = strSQL & " WHERE Day([time]) Between 1 And 5 "
strSQL = strSQL & " AND Month([time])= 1"

db.Execute strSQL, dbFailOnError
 
A

A Newbie

Thanks for your reply I know running on other action is not good but
temporary now I have no other way. I already try yours but still get same
error msg

please any other idea

thanks again
 
D

Duane Hookom

Tell us what you are attempting to do. Do you want to create a recordset or
run an action query?
What kind of field is [Time]? Is it possible that [TIme] may be null?

What exact syntax have you tried?
 
Top