If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Run-time error 3061; Too few parameters. Expected 2
Private Sub Sect_BeforeUpdate(Cancel As Integer)
Dim db As dao.Database Dim rst As dao.Recordset Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect _ & "' And [TimeIn] = #" & [Forms]![MainMenu].[From] & _ "# And [TimeOut] = #" & [Forms]![MainMenu].[To] + 1 & "#") If rst.EOF Then MsgBox Me.Sect & " is not valid section #, or" & vbCrLf _ & "no student signed in " & Me.Sect & " during the period specified.", , conAppName Cancel = True Else Me.Course = rst![Course] End If Set db = Nothing Set rst = Nothing Exit_sect_BeforeUpdate: Exit Sub Err_sect_BeforeUpdate: MsgBox Err.Description Resume Exit_sect_BeforeUpdate End Sub Above code generate error message. Help is needed. Thanks. |
#2
|
|||
|
|||
Run-time error 3061; Too few parameters. Expected 2
Does qryData have parameters? If so, those parameters need to be
resolved first before the OpenRecordSet command. |
#3
|
|||
|
|||
Run-time error 3061; Too few parameters. Expected 2
On Apr 27, 1:49*pm, ghetto_banjo wrote:
Does qryData have parameters? *If so, those parameters need to be resolved first before the OpenRecordSet command. I solved parameters in qryData and simplified OpenRecordSet as follows: Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect & "'") But I still get same error message. |
#4
|
|||
|
|||
Run-time error 3061; Too few parameters. Expected 2
How did you "solve the parameters" in qryData? It doesn't sound as if
you've done that at all. You might want to take a look at a sample on my website called TooFewParameters.mdb (http://www.rogersaccesslibrary.com/forum/topic234.html) which not only explains why you're getting the "Too Few Parameters" error, but a couple of ways to fix it. It strike me that you either need to use a querydef to recreate qryData before creating your recordset or you need to read the parameters collection. BTW, since you are creating a database variable, you might as well use it: Dim db As dao.Database Dim rst As dao.Recordset Set db = CurrentDb Set rst = db.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect _ ... -- --Roger Carlson MS Access MVP Access Database Samples: www.rogersaccesslibrary.com Want answers to your Access questions in your Email? Free subscription: http://peach.ease.lsoft.com/scripts/...UBED1=ACCESS-L "Song" wrote in message ... On Apr 27, 1:49 pm, ghetto_banjo wrote: Does qryData have parameters? If so, those parameters need to be resolved first before the OpenRecordSet command. I solved parameters in qryData and simplified OpenRecordSet as follows: Set rst = CurrentDb.OpenRecordset("Select * From qryData Where [sect] = '" & Me.Sect & "'") But I still get same error message. |
Thread Tools | |
Display Modes | |
|
|