[AccessD] Running Access Query With Parameters From VB6

Paul Hartland (ISHARP) paul.hartland at isharp.co.uk
Mon Mar 21 05:10:31 CST 2005


It works on all my other queries, just not this one....I have five query
names in strQueries(), three of which I pass date parameters to, this is the
only one not working 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: 18 March 2005 17:00
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Running Access Query With Parameters From VB6

Hi Paul

You need to pass an SQL string in strSQL. I doubt very much that this:


  strQueries(intQuery) & " '" & dtKPIStart & "', '" & dtKPIFinish & "'"

will do that.

/gustav


>>> paul.hartland at fsmail.net 03/18 5:49 pm >>>
To all,

I have a query in an Access database which is used to produce KPI reports,
the query is called qryKPI_SickDays_By_Region_By Month3 and expects a start
and finish date.  

In my VB application I have a connection to the database inside a funtion
called OpenDataConn and use the following code (dtKPIStart and dtKPIFinish
are the start and end dates).
strSQL = strQueries(intQuery) & " '" & dtKPIStart & "', '" & dtKPIFinish &
"'"
Set rsKPIData = OpenDataConn.Execute(strSQL) When I run the program I the
following error message:

Run-time error '-2147217900
Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT' or
'UPDATE

Anyone any ideas what I am doing wrong ?

Thanks for the help in advance.

Paul Hartland

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list