Connecting VB Proj to a local Access DB
Hi,
I have been going around in circles on how to pass parameters to a select query in an access database from word using DAO. I keep getting a data type conversion error every time I run it. Maybe some one could help me.
Here is the SQL statement from my Access Query:
PARAMETERS [num] Text ( 255 );
SELECT tblTestingSummaryReport.[Date of Test], tblTestingSummaryReport.Index, tblTestingSummaryReport.[Study type]
FROM tblTestingSummaryReport
WHERE (((tblTestingSummaryReport.[SDC #])=[num]));
Here is the code from my VBA app:
Dim MyWorkspace As Workspace
Dim db As Database
DBEngine.SystemDB = "System.mdw"
Set MyWorkspace = DBEngine.CreateWorkspace ("Name", "DBAPaulD", pass)
Set db = OpenDatabase("report.mdb", False, False)
Dim rs As DAO.Recordset
Dim qryDef As QueryDef
Set qryDef = db.QueryDefs("qryRembrandtGetTSRIndex")
qryDef.Parameters(0) = "13" 'This is text eventhough it is a number
'This is where it crashes
Set rs = qryDef.OpenRecordset("qryRembrandtGetTSRIndex")
Thanks
|