473,769 Members | 4,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

in DAO: Run time error 3061 Too few parameters....

I wonder what I'm missing?

I really feel like a retard because I've been screwing with some code for a
very long time. I just must be missing something very simple.
In the following example, I've stripped away everything that doesn't cause
the error to make my question a little simpler.

Here's the problem in its simplest form inside a report:

Dim db As DAO.Database
Dim rs As DAO.RecordSet

Set db = CurrentDb
Set rs = db.OpenRecordse t("SELECT * FROM qryTableOfGrade s")

'where qryTableOfGrade s is a saved crosstab query.

I get "Run time error 3061 Too few parameters. Expected 0."

but if I just make that last line:

Set rs = db.OpenRecordse t("qryTableOfGr ades")

I get "Run time error 3061 Too few parameters. Expected 1."

And if I do this:
Set rs = db.OpenRecordse t(qryTableOfGra des) ' without quotes

I get "variable not defined."

If I run the query by itself without the report it runs fine.

Jun 10 '07 #1
1 22305
There is a name in qryTableOfGrade s that Access cannot resolve to a field
name, so it interprets it as a parameter.

The parameter could be several things, e.g.:
a) Something like this:
[Forms].[Form1].[Text22]
When you run the query, the Expression Service handles that reference. But
the ES is not available in DAO code, so it is treated as an unsupplied
parameter.

b) A misspelled field name.

c) A field name in the Filter or Order By properties of the query, if the
field no longer exists.

You should be able to identify what the parameter is by closing all forms,
running the query, and seeing what name it asks for.

It is possible to supply the parameter programmaticall y, e.g.:
Dim qdf As DAO.QueryDef
Set qdf = dbEngine(0)(0). QueryDef("qryTa bleOfGrades")
qdf.Parameters( "[Forms].[Form1].[Text22]") = [Forms].[Form1].[Text22]
Set rs = qdf.OpenRecords et(...

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Richard Hollenbeck" <ri************ ****@verizon.ne twrote in message
news:6ITai.191$ cx4.168@trnddc0 7...
>I wonder what I'm missing?

I really feel like a retard because I've been screwing with some code for
a very long time. I just must be missing something very simple.
In the following example, I've stripped away everything that doesn't cause
the error to make my question a little simpler.

Here's the problem in its simplest form inside a report:

Dim db As DAO.Database
Dim rs As DAO.RecordSet

Set db = CurrentDb
Set rs = db.OpenRecordse t("SELECT * FROM qryTableOfGrade s")

'where qryTableOfGrade s is a saved crosstab query.

I get "Run time error 3061 Too few parameters. Expected 0."

but if I just make that last line:

Set rs = db.OpenRecordse t("qryTableOfGr ades")

I get "Run time error 3061 Too few parameters. Expected 1."

And if I do this:
Set rs = db.OpenRecordse t(qryTableOfGra des) ' without quotes

I get "variable not defined."

If I run the query by itself without the report it runs fine.
Jun 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
4044
by: deko | last post by:
For some reason this does not seem to be working... Am I missing something basic? Dim rst As DAO.Recordset Dim db As DAO.Database Set db = CurrentDb Set rst = db.OpenRecordset("qryEmailS") ' <= can I use query here? ' qryEmailS contains only one column - "strS" ' I want to loop through each item in the rst
0
3315
by: Miranda Evans | last post by:
I noticed several postings about issues related to "run-time error 3061", and I observed that the solutions to these issues appear to involve correcting something within the SQL code. I'm encountering the "run-time error 3061" issue, but I'm not sure how to go about correcting the SQL. My hunch is that I have not properly constructed things to identify a date field, but I don't know how to correct this issue. In addition to not...
2
1939
by: Jon | last post by:
Hello all: I'm trying to modify an existing db for someone who wants to set appointments in a customer db. They want to prevent someone from double booking appts. I've developed a few lines of code to do this, but I keep getting hung on the SQL string. Here is the code: ------ Private Function CheckAppt(SALESMAN)
6
8540
by: Jonathan LaRosa | last post by:
I am trying to open a recordset and I am getting an error and I can't figure out why. See code below. sqlString2 does not work. sqlString does. Clearly the problem is with the nested SELECT statement. But when I copy sqlString2 into a new query it runs just fine. Futhermore, I have used a nested SELECT statement with the OpenRecordset() method before and it works just fine. Any ideas? thanks much,
2
5940
by: fanfromfla | last post by:
I am using a database that has worked for many years for a holiday project for needy families. My organization recently upgraded its server and changed everyone to Windows XP. I just mention that in case that has anything to do with the problem. There are pre-set reports that can be run with this database. I am getting a Runtime Error 3061 with one of them. It says Too Few Parameters. Expected 1. I have tried to trouble-shoot, but am...
2
1933
by: Richard Hollenbeck | last post by:
I'm sure I saw this somewhere, but I'm not finding it now. I'm using Access XP. Some time ago I decided to go with DAO instead of ADO. Earlier today I found a very cool article at The Access Web at http://www.mvps.org/access/forms/frm0047.htm about having the background color change for the current record. I don't know ADO but I know **some** DAO. I suspect the code on that page is ADO, though it looks a little like DAO. I...
2
3028
by: Steve Jorgensen | last post by:
When writing VB or VBA code that works with databases or other external libraries that cannot be trusted to automatically do the right thing when references to their objects are arbitrarily released, some thought must be put into how to make sure the objects will all be closed and released in the correct order, even in the result of an error. This requirement can make our code really ugly, even following the best of commonly known best...
3
3833
by: Kassimu | last post by:
Hi there, I have a table with thousands of record entries, usually the user searches this table through SearchForm resulting into some recordset. What I need to do on this recordset is to concatenate the contents of all the records for one field-, and populate the resulting into textbox of a form Private Sub Form_Load() Dim db As Database Dim rstUpdates As Recordset Set db = CurrentDb Set rstUpdates = db.OpenRecordset("Daily...
8
2993
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1. Now the query and database are already open so I'm not entirely sure of any connection strings I may need. I think part of the problem may be that the parameter I am using to call the function is part of the query. I am not sure how to come by this...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.