Parameters for OpenRecordset in VB
Posted on 2011-02-20
I am getting the following syntax error on my OpenRecordset command in VB within MS Access:
Run-time error '3061': Too few parmaeters. Expected 3.
I am passing a single parameter which is a SQL statement. In researching correct syntax for OpenRecordset on the internet, it seems to me that only 1 parameter is required. Here is my code:
'CALL THIS FUNCTION BEFORE PAYOUT - 1D IN THE PAYOUT MACRO. This code is only called for "D" format races.
Dim db As DAO.Database
Dim class_rs As DAO.recordset
Dim EmptyDPayout As Currency 'Total amount of payout originally allocated to "D"s that are empty
Dim NumEmptyDs As Integer 'Number of "D"s with no entries
Set db = CurrentDb
Set class_rs = db.OpenRecordset("SELECT * FROM Class WHERE ((Class.EventID = [Forms]![Calculate Results]![Event ID]) AND (Class.[Class Type] = [Forms]![Calculate Results]![Calculate Results - Class Subform].[Form]![Class Type]))")
EmptyDPayout = 0
NumEmptyDs = 0