Recordset won't open

David777

New member
Local time
Today, 14:01
Joined
Mar 7, 2002
Messages
6
Greetings,
In my database I have a form that inputs a start date and end date. A query uses these dates to give wanted records. I have a module that updates a table. A command button is on the Dates form and runs the VBA code then opens a report. When the command button is pressed, I get an error of 'Too few parameters passed'. The form is still open on the line of code that opens the recordset. Do I have to pass thetext box dates to the module?. When I take out the call to the function, the query runs just fine with the right records.

Thanks,

David
 
Please post your code as it sounds like an issue with the code itself, which is hard diagnose and fix without seeing the actual syntax. Thanks! :)
 
Excuse the formatiing. I am blind and haven't found an easy way of formatting the code.


Code:
Function UpdateTally()


Dim db As Database
Set db = CurrentDb
Dim RecSet As Recordset
Set RecSet = db.OpenRecordset("Data", dbOpenDynaset)
Dim RecSet2 As Recordset
Set RecSet2 = db.OpenRecordset("Topic Tally", dbOpenDynaset)
Dim TblDef As TableDef
Dim strField As String
Dim lngE As Long
Dim lngG As Long
Dim lngF As Long
Dim lngP As Long
Dim intI As Long
Dim intNoRecs As Long

Set TblDef = db.TableDefs("Exit Interview Info Fields no data")

intI = 0
intNoRecs = 32

RecSet2.MoveFirst

'Loop Thru All Fields
Do Until intI > intNoRecs - 1

'Reset RecSet to Beginning and Move to next field
RecSet.MoveFirst

'strTopic = TblDef.Fields(intI).Name
strField = RecSet2("Topic Field")
lngE = 0
lngG = 0
lngF = 0
lngP = 0

'Loop Through All  Records
Do Until RecSet.EOF
'Select Case RecSet(TblDef.Fields(intI).Value)
Select Case RecSet(strField)
Case "Excellent"
    lngE = lngE + 1
     Case "Good"
      lngG = lngG + 1
      Case "Fair"
       lngF = lngF + 1
        Case "Poor"
         lngP = lngP + 1
         End Select
         
RecSet.MoveNext

Loop

'Update Fields in Table Topic Tally
RecSet2.Edit
RecSet2("Excellent").Value = lngE
RecSet2("Good") = lngG
RecSet2("Poor") = lngP
RecSet2("Fair") = lngF
RecSet2.Update

intI = intI + 1

RecSet2.MoveNext

Loop

RecSet.Close
RecSet2.Close
Set db = Nothing

End Function
 
Last edited by a moderator:
David777 said:
A command button is on the Dates form and runs the VBA code then opens a report. When the command button is pressed, I get an error of 'Too few parameters passed'.

What is the command button code you're using to open the report?
 
The command button code is as follows. Also, when I replace the criteria in the query from the reference to the forms text box to an actual date range, the module runs alright.


Private Sub cmdSurveyTally_Click()

Call UpdateTally
'DoCmd.RunMacro "Macro1"

DoCmd.OpenReport "Survey Topic Tally", acPreview, ""

End Sub
 

Users who are viewing this thread

Back
Top Bottom