RE: Syntax Error - Missing Operator - When Using Date !



The value for the Name parameter in the WHERE clause needs to be enclosed
with single quotes:

Where Name='SomeName'

And, depending on the local, you may have problems with the Date format when
the user setting for the Date seperator in the control panal is not in US
format (such as a period as a date part seperator as in 01.01.2006).
So, use the following instead:

Format$(PickDate.List(PickDate.ListIndex), "mm\/dd\/yyyy")
Using "\" forces the Format function to use "/"

or better use the ISO 8601 format:

Format$(PickDate.List(PickDate.ListIndex), "yyyy-mm-dd")


"lovely_angel_for_you@xxxxxxxxx" wrote:

Hi,

I have this query to pull the data out from the system. And whenever I
run this, I get the "Syntax Error (Missing Operator)" Error displayed.

Set conn = New ADODB.Connection
FilePath = App.Path & "\Calls.mdb"
With conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & FilePath & ";"
.Open
End With
'Set rdset = New ADODB.Recordset

'The following is single string, it just gets wrapped up.
Set rdset = conn.Execute("SELECT * FROM InputData Where Name=" &
Name.Text & " AND DateNow=#" &
Format$(PickDate.List(PickDate.ListIndex), "mm/dd/yyyy") & "#")
'And then I get to use the data here.
rdset.Close
conn.Close


Any help on the above will be greatly appreciated.

Thanks & Regards
Harnek Singh


.



Relevant Pages

  • Re: DBI Issue with MySQL query
    ... to compensate for both Perl and MySQL stripping escape characters. ... you say you get a malformed SQL syntax error. ... single quotes, double quotes, escaped ...
    (perl.dbi.users)
  • Re: DBI Issue with MySQL query
    ... Thank you all for all the suggestions and time you spent on my non-problem. ... to compensate for both Perl and MySQL stripping escape characters. ... you say you get a malformed SQL syntax error. ... single quotes, double quotes, escaped ...
    (perl.dbi.users)
  • Re: Password
    ... You are using single quotes for empty password. ... Error generated as "Syntax error in ALTER TABLE" ... The reason is that I tried to compact a MDB database and it does not ...
    (microsoft.public.fox.vfp.forms)
  • Re: SQL Syntax
    ... There is no syntax error. ... 6/1/2009) is displayed in the SQL produced. ... You need single quotes around the date in the same way you ... try setting a username of: ...
    (microsoft.public.vb.database.ado)
  • Re: datevalue
    ... "Govind" wrote: ... > Your first two values were within single quotes and hence they wont ... On the third format, am not sure of the reason why it doesnt work, ... >> When I try to use the function DateValue, I keep getting an error message of ...
    (microsoft.public.excel.worksheet.functions)