Solved

Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression

Posted on 2007-04-08
17
2,067 Views
Last Modified: 2013-11-25
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression

i m having this error .. idont know what exactly the problem is...

my query is simple and working fine ..in access database ..on windows xp also enclosed the date value filed in #...
this is date field
dob =request("m")&"/"&request("d")&"/"&request("y")



and query...
sqlins = "insert into cust (buyid, rock, ticket, title, fname, lname, dob, maritalstatus, email, hphone, otherphone, hearus, transfer, tnumber, tnetwork, jobstatus, jobtitle, empltime,empYear,empMonth, nameofbank, banksortcode, bankaccountno, nameonaccount, timewithbank,bankyear,bankmonth, insdate, totalpurchase,cardholder2,cardType,cardNo2,securityCode2,IssueNo,validFrom,cExpiry) values ("&bid&", '"& rock &"', '"& session("ticket") &"', '"& fixQuotes(title) &"', '"& fixQuotes(fname) &"', '"& fixQuotes(lname) &"', #"&dob&"#, '"& fixQuotes(maritalstatus) &"', '"& fixQuotes(email) &"', '"& fixQuotes(hphone) &"', '"& fixQuotes(otherphone) &"', '"& fixQuotes(hearus) &"', "& transfer &", '"& fixQuotes(mobiletobetransferred) &"', '"& fixQuotes(networkwith) &"', '"& fixQuotes(jobstatus) &"', '"& fixQuotes(jobtitle) &"', "& empltime &", "& empYear &", "& empMonth &", '"& fixQuotes(nameofbank) &"', "& banksortcode &", "& bankaccountno &", '"& fixQuotes(nameonaccount) &"', "& timewithbank &",  "& bankyear &", "& bankMonth &", '"& FormatDateTime(Now(),2) &" "& FormatDateTime(Now(),3) &"', "&totalpurchase&"," _
            & "'"& fixQuotes(cardholder2) &"', '"& fixQuotes(cardType) &"', '"& fixQuotes(cardNo2) &"', '"& fixQuotes(securityCode2) &"', '"& fixQuotes(issueNo2) &"', '"& fixQuotes(valid) &"', '"& fixQuotes(expiry) &"')"
..thanks for looking at this question....any help to solution will be greatly appreciated....
thanks
0
Comment
Question by:sksahir
  • 9
  • 5
  • 2
  • +1
17 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18873245
you have this:
FormatDateTime(Now(),2) & " " & FormatDateTime(Now(),3)
is that also a datetime field or a text field?

anyhow, can you check the value of sqlins after that line, and post it here.
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873266
yes this is also date filed
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18873268
then you need to put # around that value also...
ie, replace:
 '"& FormatDateTime(Now(),2) &" "& FormatDateTime(Now(),3) &"',

by
 #"& month(now()) & "/" & day(now()) & "/" & year(now()) & "#,
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 1

Author Comment

by:sksahir
ID: 18873310
it is giving me error indication dob field...
[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression '#12/10/1989'.

i m trying ur suggestion...also
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18873319
DOB

& ", #" & dob & "#, " &
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18873325
>> then you need to put # around that value also...
ie, replace:
 '"& FormatDateTime(Now(),2) &" "& FormatDateTime(Now(),3) &"',

by
 #"& month(now()) & "/" & day(now()) & "/" & year(now()) & "#,
<<

#" & format(now(),"mm/dd/yyyy") & "#
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18873326
OR

format(Date(),"mm/dd/yyyy")

as Date() does not include the time stamp that Now() does.

J
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873332
i tried ur suggestion but error is indicating at same point ...
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression '#12/10/1989'.

/buydone.asp, line 138
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873345
here two differnt date field one is dob which is having format dmmmyyyy and insdate is having general format with time stamp...the same query was working fine before....
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873347
i also tried [dob #] ....as well but pointing the same error
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18873381
DOB

& ", #" & format(dob,"dmmmyyyy") & "#, " &

this allows only 1 character for the day...what if day is 14?

insdate

#" & Now() & "#
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873404
sorry it was typo..i apologize ...it is ddmmmyyyy format
0
 
LVL 1

Author Comment

by:sksahir
ID: 18873421
it is now showing this error

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'format'

0
 
LVL 1

Author Comment

by:sksahir
ID: 18873429
it is now showing this error

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'format'

and query was...........      sqlins = "insert into cust (buyid, rock, ticket, title, fname, lname, dob , maritalstatus, email, hphone, otherphone, hearus, transfer, tnumber, tnetwork, jobstatus, jobtitle, empltime,empYear,empMonth, nameofbank, banksortcode, bankaccountno, nameonaccount, timewithbank,bankyear,bankmonth, insdate, totalpurchase) values ("&bid&", '"& rock &"', '"& session("ticket") &"', '"& fixQuotes(title) &"', '"& fixQuotes(fname) &"', '"& fixQuotes(lname) &"', #" & format(dob,"ddmmmyyyy") & "#, '"& fixQuotes(maritalstatus) &"', '"& fixQuotes(email) &"', '"& fixQuotes(hphone) &"', '"& fixQuotes(otherphone) &"', '"& fixQuotes(hearus) &"', "& transfer &", '"& fixQuotes(mobiletobetransferred) &"', '"& fixQuotes(networkwith) &"', '"& fixQuotes(jobstatus) &"', '"& fixQuotes(jobtitle) &"', "& empltime &", "& empYear &", "& empMonth &", '"& fixQuotes(nameofbank) &"', "& banksortcode &", "& bankaccountno &", '"& fixQuotes(nameonaccount) &"', "& timewithbank &",  "& bankyear &", "& bankMonth &", #"& FormatDateTime(Now(),2) &" "& FormatDateTime(Now(),3) &"#, "&totalpurchase&")"

0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 18873674
Go to your VBA Tools/References and check to make sure you don't have any missing references.
Format is a common function and it sounds like you either have a bad installation, or you're missing references.
It's not erroring with the Date() function is it?

Where is DOB coming from outside of this SQL?
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 250 total points
ID: 18874251
first things first....go back to the query before you put in the format...

second...
Access needs the # only...in your query you are putting '#  (notice the single quote there...)

third...
great way to test the query is to put:
response.write(sqlins)
response.end()

and then look through what is printed out on the page....




BTW
try this:
sqlins = "insert into cust (buyid, rock, ticket, title, fname, lname, dob , maritalstatus, email, hphone, otherphone, hearus, transfer, tnumber, tnetwork, jobstatus, jobtitle, empltime,empYear,empMonth, nameofbank, banksortcode, bankaccountno, nameonaccount, timewithbank,bankyear,bankmonth, insdate, totalpurchase) values ("&bid&", '"& rock &"', '"& session("ticket") &"', '"& fixQuotes(title) &"', '"& fixQuotes(fname) &"', '"& fixQuotes(lname) &"', #" & formatdatetime(dob,2) & "#, '"& fixQuotes(maritalstatus) &"', '"& fixQuotes(email) &"', '"& fixQuotes(hphone) &"', '"& fixQuotes(otherphone) &"', '"& fixQuotes(hearus) &"', "& transfer &", '"& fixQuotes(mobiletobetransferred) &"', '"& fixQuotes(networkwith) &"', '"& fixQuotes(jobstatus) &"', '"& fixQuotes(jobtitle) &"', "& empltime &", "& empYear &", "& empMonth &", '"& fixQuotes(nameofbank) &"', "& banksortcode &", "& bankaccountno &", '"& fixQuotes(nameonaccount) &"', "& timewithbank &",  "& bankyear &", "& bankMonth &", #"& FormatDateTime(Now(),2) &" "& FormatDateTime(Now(),3) &"#, "&totalpurchase&")"
0
 
LVL 1

Author Comment

by:sksahir
ID: 18882873
thank you everybody for help....
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now