|
Question : OpenRecordSet querydef with parameter problem Access 97
|
|
Greetings,
I've coded a form with a single control (date), and use it as a parameter in a query I'm trying to run as the after update event of the form. I get runtime error 3061: Too few parameters expected 1.
I've looked in the Developer's Handbook and Access Power Programming texts and have tried the following code (the first attempt is commented out).
Private Sub EventDate_AfterUpdate()
Dim rstQry As Recordset Dim rstTbl As Recordset Dim db As Database Dim qdf As QueryDef Dim prm As Parameter
'delete contents of table each time
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE tblChoirAttendance.Name FROM tblChoirAttendance;"
DoCmd.SetWarnings True
Set db = CurrentDb()
' set up parameter for query
Set qdf = db.QueryDefs("qryAttendanceChoir") 'For Each prm In qdf.Parameters 'prm.Value = Eval(prm.Name) 'Debug.Print prm.Value 'Next prm
qdf![Forms!frmChoirEventDate!EventDate] = Forms![frmChoirEventDate]![EventDate]
Set rstQry = db.OpenRecordset("qryAttendanceChoir", dbOpenDynaset)
Does anyone know what I did wrong?
Sam
|
|
Answer : OpenRecordSet querydef with parameter problem Access 97
|
|
Sorry I didn't notice it earlier. You were setting the parameters OK but not using the querydef (and therefore parameters) to open the recordset.
Anyway glad it works now.
|
|
|