Hi,
I get the Too Few Parameters. Expected 1 error message when i run the following code - Set dbsClient = CurrentDb
-
Set rstCheck = _
-
dbsClient.OpenRecordset("Q_SelEquipTmpTbl", dbOpenDynaset)
I am referencing a combo box on a form in the query criteria - Like [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
when i take the reference to the combo box out of the query it works.
please help
Regards Phill
9 5230
Hi,
I get the Too Few Parameters. Expected 1 error message when i run the following code
Set dbsClient = CurrentDb
Set rstCheck = _
dbsClient.OpenRecordset("Q_SelEquipTmpTbl", dbOpenDynaset)
I am referencing a combo box on a form in the query criteria
Like [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
when i take the reference to the combo box out of the query it works.
please help
Regards Phill
There is obviously a problem resolving the single Query Parameter. You can always Open the Recordset directly from the SQL in Q_SelEquipTmpTbl, namely: -
Dim MySQL As String
-
Dim MyDB As DAO.Database
-
Dim MyRS As DAO.Recordset
-
-
'Assuming [SFEquipID] is Numeric
-
MySQL = "SQL from Q_SelEquipTmpTbl with the WHERE Clause similar to [SomeField] Like " & _
-
[Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
-
-
Set MyDB = CurrentDb()
-
Set MyRS = MyDB.OpenRecordset(MySQL, dbOpenDynaset)
NeoPa 32,556
Expert Mod 16PB
As a matter of interest, post what you get running the following SQL (in the same circumstances where you get the above error running your query) : - SELECT [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
You will have to run it from the SQL view as it (run) won't be available from any other view.
As a matter of interest, post what you get running the following SQL (in the same circumstances where you get the above error running your query) : - SELECT [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
You will have to run it from the SQL view as it (run) won't be available from any other view.
Hello NeoPa, I could be wrong but I think that the problem is a little more sinister than it actually appears. I don't think that you can create a Traditional Recordset on a QueryDef Object whose Parameter is a Control on a Form/Sub-Form. I don't think that it can be resolved in this fashion. The code in Post #2, however, will work and also the code posted below, as long as the Like Operator is not utilized. As always, let me know what you think - I'm probably wrong, anyway, ergo not directing the Reply to the OP. (LOL). -
NOTE: The actual Prompt you use in Q_SelEquipTmpTbl is irrelevant, since the only Parameter is indicated by an Index, and not a literal String Value
-
-
Dim dbsClient As DAO.Database
-
Dim rstCheck As DAO.Recordset
-
Dim qdf As DAO.QueryDef
-
-
Set dbsClient = CurrentDb()
-
Set qdf = dbsClient.QueryDefs("Q_SelEquipTmpTbl")
-
-
qdf.Parameters(0) = [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
-
-
Set rstCheck = qdf.OpenRecordset(dbOpenDynaset, dbReadOnly)
-
-
Do While Not rstCheck.EOF
-
'Loop code here, set to Read Only
-
rstCheck.MoveNext
-
Loop
-
-
rstCheck.Close
-
Set rstCheck = Nothing
NeoPa 32,556
Expert Mod 16PB
ADezii, You posted the same thing twice so I deleted the first one.
The SQL I suggested should work. It's a little weird I know but give it a try ;)
It's not to fix the problem though. Simply to provide some information and hopefully identify what might NOT be the problem.
ADezii, You posted the same thing twice so I deleted the first one.
The SQL I suggested should work. It's a little weird I know but give it a try ;)
It's not to fix the problem though. Simply to provide some information and hopefully identify what might NOT be the problem.
You posted the same thing twice so I deleted the first one.
Thanks NeoPa
The SQL I suggested should work.
The SQL you posted will definately work. What I was referring to was the OP's logic, namely: Creating a Recordset on a Query whose Criteria is a Control on a Sub-Form.
NeoPa 32,556
Expert Mod 16PB
... namely: Creating a Recordset on a Query whose Criteria is a Control on a Sub-Form.
Although I very rarely use that concept myself (I build up SQL strings in VBA where possible), I know that most people seem to use that as a standard way of filtering on selected (form) items. I think that's what you're referring to. Excuse me if I've misunderstood again.
For it to work, the reference must be an absolute one (usually means using the Forms() collection). This is because the SQL engine (processor) is not executing from within the current code but is independent of it.
Hello NeoPa, I could be wrong but I think that the problem is a little more sinister than it actually appears. I don't think that you can create a Traditional Recordset on a QueryDef Object whose Parameter is a Control on a Form/Sub-Form. I don't think that it can be resolved in this fashion. The code in Post #2, however, will work and also the code posted below, as long as the Like Operator is not utilized. As always, let me know what you think - I'm probably wrong, anyway, ergo not directing the Reply to the OP. (LOL). -
NOTE: The actual Prompt you use in Q_SelEquipTmpTbl is irrelevant, since the only Parameter is indicated by an Index, and not a literal String Value
-
-
Dim dbsClient As DAO.Database
-
Dim rstCheck As DAO.Recordset
-
Dim qdf As DAO.QueryDef
-
-
Set dbsClient = CurrentDb()
-
Set qdf = dbsClient.QueryDefs("Q_SelEquipTmpTbl")
-
-
qdf.Parameters(0) = [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
-
-
Set rstCheck = qdf.OpenRecordset(dbOpenDynaset, dbReadOnly)
-
-
Do While Not rstCheck.EOF
-
'Loop code here, set to Read Only
-
rstCheck.MoveNext
-
Loop
-
-
rstCheck.Close
-
Set rstCheck = Nothing
Hi ADezii
its sorted thanks for your help
Cheers Phill
As a matter of interest, post what you get running the following SQL (in the same circumstances where you get the above error running your query) : - SELECT [Forms]![F_EquipBooking].[SF_EquipBooking]![SFEquipID]
You will have to run it from the SQL view as it (run) won't be available from any other view.
Hi NeoPa,
Thanks its sorted
Cheers Phill
NeoPa 32,556
Expert Mod 16PB
Good for you Phill, and thanks for letting us know :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Not Me |
last post by:
Hi,
When I do the following in vba:
Set rst = db.OpenRecordset(sql)
I get the too few parameters (expected 3) error. I've seen quite a lot of
this on google but all seem to be caused by...
|
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
|
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...
|
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...
|
by: Greg Pyle |
last post by:
I have created a parameter query (qryAuthors) that reads three parameters
from three different fields on a subform (Subform1). Each time the form
record changes, the query updates automatically. ...
|
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...
|
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,...
|
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...
|
by: phill86 |
last post by:
Hi,
I am trying to run the following query in a recordset and i get the following error message
Runtime error 3061 - Too few parameters. Expected 1
i am using the following code
|
by: JGrizz |
last post by:
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |