Syntax error on date field

shery1995

Member
Local time
Today, 11:46
Joined
May 29, 2010
Messages
71
Hi All

I am trying the following line of code:

strCriteria = "[MatterDate] Between " & Format(Me.txtDateFrom, "\#dd\/mm\/yyyy\#) & " And " & Format(Me.txtDateTo, "\#dd\/mm\/yyyy\#")

But getting Syntax error message. Will much appreciate if someone can help to to sort it out.

Many thanks
 
You are missing one closing "

strCriteria = "[MatterDate] Between " & Format(Me.txtDateFrom, "\#dd\/mm\/yyyy\#") & " And " & Format(Me.txtDateTo, "\#dd\/mm\/yyyy\#")
 
Hi. That code will probably result in unexpected outcome anyway. Suggest using the format "yyyy-mm-dd" to avoid potential problems/issues.
 
Also Debug.Print the variable to see the error ?
 
Hi. That code will probably result in unexpected outcome anyway. Suggest using the format "yyyy-mm-dd" to avoid potential problems/issues.
Thank you for your reply. Format requirement is dd/mm/yyyy.
 
You are missing one closing "

strCriteria = "[MatterDate] Between " & Format(Me.txtDateFrom, "\#dd\/mm\/yyyy\#") & " And " & Format(Me.txtDateTo, "\#dd\/mm\/yyyy\#")
Thank you for your reply. Can you please point where exactly closing is missing?
 
To save typing and get it correct look at the CSQL function
 
I use the below you need to format for a US date

Code:
int([EventDate]) BETWEEN " & Format(Me![txt_From], "\#" & "mm/dd/yyyy" & "\#") & " AND " & Format(Me![txt_To], "\#" & "mm/dd/yyyy" & "\#")
 
I use the below you need to format for a US date

Code:
int([EventDate]) BETWEEN " & Format(Me![txt_From], "\#" & "mm/dd/yyyy" & "\#") & " AND " & Format(Me![txt_To], "\#" & "mm/dd/yyyy" & "\#")
Many hanks
 
I can never quite remember the correct syntax and use this that I found on the web.
Code:
Public Const strcJetDate = "\#mm\/dd\/yyyy\#"  'Needed for dates in queries as Access expects USA format.
 

Users who are viewing this thread

Back
Top Bottom