Problematic SQL statement

  • Thread starter George Papadopoulos
  • 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
 
D

david epsom dot com dot au

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)
 
G

George Papadopoulos

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)
 
V

Van T. Dinh

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.
 
D

david epsom dot com dot au

VTD's message in this thread shows how to write your SQL for
PC's with European date format.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top