A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Run-time error 3061; Too few parameters. Expected 2



 
 
Thread Tools Display Modes
  #1  
Old April 27th, 2010, 09:30 PM posted to microsoft.public.access
Song[_4_]
external usenet poster
 
Posts: 43
Default 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  
Old April 27th, 2010, 09:49 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default 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  
Old April 27th, 2010, 10:27 PM posted to microsoft.public.access
Song[_4_]
external usenet poster
 
Posts: 43
Default 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  
Old April 28th, 2010, 01:27 PM posted to microsoft.public.access
Roger Carlson
external usenet poster
 
Posts: 824
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.