Problematic SQL statement

  • Thread starter Thread starter George Papadopoulos
  • Start date Start date
G

George Papadopoulos

I am trying to express an SQL statement under VBA. The code I`m using is :

strSelect = "Select Kwdikos_episkeyhs, Kwdikos_klinikhs,
Kwdikos_mhxanhmatos FROM EPISKEYH WHERE Kwdikos_texnikou ='" &
Me.Kwdikos_Texnikou.Value & "'" & "Hmeromhnia >=" #Me.From_Date.Value &
"Hmeromhnia <=" #Me.To_Date.Value

I get a syntax error with this statement. What am i not phrasing correctly?

Thx, in advance

George Papadopoulos
 
Create the query in the Access query window, then paste it into
your code and modify it.

"WHERE (Kwdikos_texnikou ='" & Me.Kwdikos_Texnikou.Value _
& "') and (" & "Hmeromhnia >=#" & Me.From_Date.Value _
& "#) and (" & Hmeromhnia <= #" & Me.To_Date.Value & "#);"

Do you use ammerican or japanese date format (mm-dd-yy or
yyyy-mm-dd)? If not your SQL will work but give the wrong
values.

(david)
 
No, I use standard European dates.

Ï "david epsom dot com dot au said:
Create the query in the Access query window, then paste it into
your code and modify it.

"WHERE (Kwdikos_texnikou ='" & Me.Kwdikos_Texnikou.Value _
& "') and (" & "Hmeromhnia >=#" & Me.From_Date.Value _
& "#) and (" & Hmeromhnia <= #" & Me.To_Date.Value & "#);"

Do you use ammerican or japanese date format (mm-dd-yy or
yyyy-mm-dd)? If not your SQL will work but give the wrong
values.

(david)
 
Try:

strSelect = "SELECT Kwdikos_episkeyhs, Kwdikos_klinikhs, Kwdikos_mhxanhmatos
" & _
" FROM EPISKEYH WHERE (Kwdikos_texnikou = '" & _
Me.Kwdikos_Texnikou.Value & "') AND (Hmeromhnia BETWEEN " & _
Format(Me.From_Date.Value, "\#mm/dd/yyyy\#) & " And " & _
Format(Me.To_Date.Value, "\#mm/dd/yyyy\#") & ")"

assuming [Kwdikos_texnikou] is a Text field and [Hmeromhnia] is a Date
field.
 
VTD's message in this thread shows how to write your SQL for
PC's with European date format.

(david)
 
Back
Top