Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatePart query works from Access but not from VB/ADO 1

Status
Not open for further replies.

Sashanan2

Programmer
Jul 2, 2004
39
NL
In one of my queries I am trying to retrieve the month from a date field. Using the DATEPART() function for this as follows:

SELECT DATEPART("m",[Datum]) AS Datum_uitgifte FROM Norm

This query works fine if I execute it in the query design window in Access, but as soon as I try to use this exact same query from my Visual Basic 6 application using ADO, I get the following error:

Run-time error '-2147217904 (80040e10)':

[Microsoft][ODBC Microsoft Access-driver] Too few parameters. Expected 1


A Google search on this error revealed that it often occurs when you try to refer to a column that doesn't exist. Figured that might be it, but I doublechecked my table and column names and they're just fine. (Besides, if they weren't, why would the query work in Access?)

This one has me stumped. Anybody know what I'm overlooking?
 
Have you tried this ?
strSQL="SELECT DatePart('m',Norm.Datum) AS Datum_uitgifte FROM Norm"
Or this ?
strSQL="SELECT Month(Norm.Datum) AS Datum_uitgifte FROM Norm"
Or this ?
strSQL="SELECT Format(Norm.Datum, 'mm') AS Datum_uitgifte FROM Norm"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The Month() solution works. Still a little curious why I had problems with my initial one (even after specifying the table along with the column name), but it works now and that's what counts. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top