Converting Access string to DBTYPE_DATE

Posted on 2013-09-13
Medium Priority
Last Modified: 2013-09-17
I'm using Access 2010 and have a routine that sends parameters to an Oracle procedure.
It works great for strings (adChar) and Numbers(adDouble) but I'm trying to send it a date.
I think it needs a DBTYPE_DATE.

I dim:
Dim cPW As New ADODB.Command
Dim aPNames() As ADODB.Parameter

Then I set the "core":
Set aPNames(iCount) = cPW.CreateParameter(, adDBDate, adParamInput)

Then I get to the point where I assign the value
  cPW.Parameters.Append aPNames(iCount)
  aPNames(iCount).Value = aParam(iCount, 3)

aParam is a string array. Aparam(iCount,3) is "20110501".

I get the error:
Application uses a value of the wrong type for the operation

What do I need to send it  and how do I get there?
Question by:GNOVAK
LVL 47

Accepted Solution

aikimark earned 2000 total points
ID: 39491093
Try one of these:

Left("20110501",4) & "-" & Mid("20110501",5,2) & "-" & Right("20110501",2)

Dateserial(Left("20110501",4) , Mid("20110501",5,2) , Right("20110501",2))

Author Closing Comment

ID: 39500193
Either one does work - Thanks!!!!!

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

623 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