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,066 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
 
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 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

26 Experts available now in Live!

Get 1:1 Help Now