473,804 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Too Few Parameters. Expected 6 - Query in VBA Issue

10 New Member
Greetings, I first off want to state that I am new to the forum, so if this question ends up in the wrong area, I apologize. This pertains to Access 2003/VBA/SQL issues...

I have been doing some investigating regarding the error which I will explain shortly, and thus far it has all pertained to WHERE clauses relating to forms causing errors when transferred over to VBA.

My issue is a wee bit different and I will explain the situation below. I have a query of a query at the moment which is made up of the following SQL code:
Expand|Select|Wrap|Line Numbers
  1. SELECT [Shop_Order_Number] & " " & [Document_Description] AS Description, Count([Chart Filter Query].Revision_Number) AS [Number of Passes]
  2. FROM [Chart Filter Query]
  3. GROUP BY [Shop_Order_Number] & " " & [Document_Description];
When I attempt to set this query as a recordset in VBA I get the too few parameters error. Since none of this data comes from a form (it is all from another query) I can not figure out for the life of me what the issue is. I will keep this post short and answer more questions as needed, but the error is occuring when I attempt to set the recordset. That code is shown below:

Set rs1 = db.OpenRecordse t("Number of Passes Chart Query", dbOpenDynaset)

Much abliged,

JGrizz
Dec 7 '09 #1
18 7256
ADezii
8,834 Recognized Expert Expert
  1. Does it Run within the Query Grid?
  2. Has the Object variable db been Declared and Instantiated, as in:
    Expand|Select|Wrap|Line Numbers
    1. Dim db As DAO.Database
    2.  
    3. Set db = CurrentDb
Dec 7 '09 #2
JGrizz
10 New Member
In response to question 1: Yes, the query runs fine when I don't need to load it as an active recordset. In fact, I have a command after which exports the query to Excel with no problem. All of the data is present that needs to be represented and it exports the data nicely over to Excel (via a command in VBA in the same section of code further down).

In response to question 2: Yes, the proper initialization did occur. I did not want to include the declarations, as I did not know if I would be supplying too much information.

When I was programming I had to perform two subsections for testing. I completed the first task (which included sending data to Excel directly from the query), and now I need to further manipulate the data in the query to send additional information to Excel.

The second round of manipulation (which I am currently performing) requires that I be able to open the query as a recordset. I have tested my code and it works properly when dealing with a test table, it however choked on the query of a query. It errors on the set rs1 = etc.....

Let me know if you need any more information. I would supply my code directly, but I do not want to provide too much code that I already know is functioning without it being necessary.
Dec 7 '09 #3
ADezii
8,834 Recognized Expert Expert
Do the [Shop_Order_Numb er], [Document_Descri ption], and [Revision_Number] Fields exist in the Chart Filter Query?
Dec 7 '09 #4
JGrizz
10 New Member
Yes, the fields exist in the Chart Filter Query. In an attempt to get past the lighter details, here are a few images to help hopefully cover any other questions. Sorry for not providing all of this information in the beginning, as I said, I am new to posting questions like this and don't know exactly what needs supplied.

Image- Number of Passes Chart Query Design View:
Attachment 1

Image- Chart Filter Query Design View:
Attachment 2

Image- Section of Code Under Consideration- Attachment 3

The cases come from a pull down on the form which this chart will be generated from. The form itself has no table/query/etc. behind it, it is meant purely to be used as a filtering source based on the user's selected criteria. Again, as I said, the error comes from calling the query as a recordset. I need to be able to manipulate the data within the query (shown in the code) before moving on to the next step. I could always create a temp table to place the information from the query on, but I feel that is sloppy programming and supplying a bandaid as opposed to a solution. Also, I will need to do similar manipulations a few more times to generate other results important to this database, so having a temp table for 4 manipulations quickly gets out of hand.

Thanks,
JGrizz
Attached Images
File Type: jpg Num_Passes_Query.jpg (18.6 KB, 606 views)
File Type: jpg Chart_Filter_Query.jpg (13.6 KB, 450 views)
File Type: jpg VBA_Code.jpg (10.0 KB, 726 views)
Dec 8 '09 #5
ADezii
8,834 Recognized Expert Expert
The Error appears to indicate that a Parameter is expected and is not being received:
  1. Try fully qualifying the SQL Statement, as in:
    Expand|Select|Wrap|Line Numbers
    1. SELECT [Chart Filter Query].[Shop_Order_Number] & " " & [Chart Filter Query].[Document_Description] AS Description,
    2. Count([Chart Filter Query].Revision_Number) As [Number of Passes]
    3. FROM [Chart Filter Query]
    4. GROUP BY [Chart Filter Query].[Shop_Order_Number] & " " & [Chart Filter Query].[Document_Description];
  2. Double check the Syntax of you Criteria in the 2nd Query, eliminating all of them, then adding one at a time since a Form or Control Reference may be incorrect.
  3. Is the Form 'Open' when the 2nd Query is executed?
  4. If all else fails, can you E-Mail me the DB to my Private Address?
Dec 8 '09 #6
JGrizz
10 New Member
ADezii,

I attempted item 1, and still received the same error.

In regards to item 2, do you believe that the controls from the Chart Filter Query are affecting the output of the Number of Passes Chart Query? I can see where you might be coming from in that case, as that would go back to similar problems in other posts dealing with the WHERE clause from form data. The Query behind the Chart Filter Query, called the Pre-Chart Filter Query, contains similar filters (there were so many filters occuring that I had to do a query of a query just to get all of the filters implemented).

For item 3, yes the form is open when all of this occurs. The filters used in the Pre-Chart Filter Query and Chart Filter Query are generated from the form via a series of pulldowns. These help to drive the final query and as I said in item 2, could possibly be afftecting the "parameters " complaint, as I do believe there are 6 filtering points. Attached is an image of the form with the series of pulldowns.See Attachment 1.

If you could tell me how to properly/fully reference the form data in the queries which supply the information for the Number of Passes Chart Query, then I will attempt to 'fix' this issue in that manner.

Let me know what you think.

Again thanks for the continued effort,

JGrizz

P.S. I also decided to attach the design view of the very first Query, the Pre-Chart Filter Query, so you can see the mess that is the filtering going on in there (I wish access had a better option, but for now it works, and if it ain't broke don't fix it). See Attachment 2.
Attached Images
File Type: jpg Select_Chart_Form.jpg (10.6 KB, 518 views)
File Type: jpg Pre-Chart_Query.jpg (19.8 KB, 485 views)
Dec 8 '09 #7
ADezii
8,834 Recognized Expert Expert
If I understand you correctly, you are trying to create a Recordset based on a Query, which in turn in based on another Query (Chart Filter Query), which in turn is based on even another Query (Pre-Chart Filter Query). Within these Queries are nested approximately 15 assorted Criteria (Form-Control references) with various Logical AND and OR Operations. Is all this correct?
Dec 8 '09 #8
JGrizz
10 New Member
Yes, quite the fustercluck isn't it? I will admit its quite a mess, but by my knowledge (which is limited and only as expansive as I've come to learn from trial and error and reading online help posts such as this) that was the only way to go about it. The worst part is that the Query is only able to have so many Criteria, otherwise, there would be only 2 Queries. The Chart Filter Query is going to serve as the basis to generate a series of charts in Excel, one of which is number of passes.

Thanks again.

I will say that there shouldn't be 15 different Criteria, it is all based on 6 criteria, but all options included there-in, if that makes sense. So A & B, Not C; A & C, Not B; etc. etc.
Dec 8 '09 #9
ADezii
8,834 Recognized Expert Expert
A brainstorm!
  1. Modify Pre-Chart Filter Query to make it a Make Table Query.
  2. Base the Chart Filter Query on the newly created Table.
  3. Base the Final Query on the Chart Filter Query.
  4. I am now out of Options unless you want to send the DB to my Personal E-Maill Address (LOL).
Dec 8 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1685
by: Dokter Z | last post by:
We are running into problems on our development environment with extra parameters being added on to a stored procedure call. Instead of the expected stored procedure call, the trace shows something like this: declare @P1 int set @P1=NULL <<expected stored procedure call>> , @P1 output, <<repeat of first three sp parms>> select @P1
11
3057
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html> <http://www.physci.org/test/003url/index.html?url=http://mybiz.com/&that=this&when=now#21> <http://www.physci.org/test/003url/index.html?url=http://mybiz.com/&when=now> Before I go offering it in public (and writing it into any number of the 'development kits'...
7
9481
by: Dee | last post by:
Running an AfterUpdate event procedure, I get the following error: "Too few parameters. Expected 1." My code is as follows: Private Sub DealerID_AfterUpdate() Dim db As DAO.Database
3
23179
by: Ryan Hubbard | last post by:
I would like to run a query from VBA. The query will be one with parameters. Is there a way to run the query and have Access prompt for the values like it does if I where to execute it through the database window?
7
21643
by: Zlatko Matiæ | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
6
2837
by: Michael R | last post by:
Please help me with this. I have a form in which I would like to present results from a CrossTab query in a subform. I don't need the query to be bounded to a master field. Also, I have a parameter in the query as one of the main form controls. Please look at the query: PARAMETERS !! Long; TRANSFORM Sum(LoansSumAmountAndYearAndCity.Amount) AS SumOfAmount SELECT LoansSumAmountAndYearAndCity.Customers.Id,...
5
5776
by: billelev | last post by:
Hi There, I am trying to execute a query using openRecordset on a query called 'AccountValues'. The 'AccountValues' query relies on another query, 'Prices', which in turn relies on a form for two parameters. The information flow is: 2 parameters -> Prices -> AccountBalances -> {my query} Ideally, I would be able to perform the following:
1
22308
by: Richard Hollenbeck | last post by:
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
5
3216
by: J055 | last post by:
Hi I've got an update business object method which takes about 80 parameters. I'm getting the 'could not find a non-generic method' error. I know that the ObjectDataSource UpdateParameters matches the business object method signiture. I ran the code below to discover that the InputParameters is in fact a list of bound values in my FormView control, i.e. not the UpdateParameters list. protected void ObjectDataSource_Updating(object...
0
9715
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
10600
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
10097
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
7642
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
6867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5535
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...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.