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,063 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]
Comment Utility
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
Comment Utility
yes this is also date filed
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
 
LVL 1

Author Comment

by:sksahir
Comment Utility
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
Comment Utility
DOB

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

Expert Comment

by:jefftwilley
Comment Utility
>> 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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:sksahir
Comment Utility
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
Comment Utility
i also tried [dob #] ....as well but pointing the same error
0
 
LVL 34

Expert Comment

by:jefftwilley
Comment Utility
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
Comment Utility
sorry it was typo..i apologize ...it is ddmmmyyyy format
0
 
LVL 1

Author Comment

by:sksahir
Comment Utility
it is now showing this error

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'format'

0
 
LVL 1

Author Comment

by:sksahir
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
thank you everybody for help....
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

744 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

17 Experts available now in Live!

Get 1:1 Help Now