473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Too few parameters. Expected 1. Error

Dee
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
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")
Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing

End Sub
The query returns only one field from one record of a table with 150
records. The field is a yes/no check field.

The query is a select query called "QrCheckDlrAssigned".
The field colums is name is "Dlr assigned".

I'm sort of a newbie and have a little problem understanding some of
the terms a read in other posts. Still don't know what DAO, stands
for.
Nov 12 '05 #1
7 9462
My guess is that your query uses a reference to a form control as a parameter.
This works fine when you use run the query manually or use it as a
recordsource or rowsource, but when you run the query from code via DAO calls
as you are doing here, all parameters must be entered explicilty using the
..Parameters collection of the querydef prior to executing .OpenRecordset.

On 7 Jan 2004 22:53:04 -0800, wo********@comcast.net (Dee) wrote:
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
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")
Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing

End Sub
The query returns only one field from one record of a table with 150
records. The field is a yes/no check field.

The query is a select query called "QrCheckDlrAssigned".
The field colums is name is "Dlr assigned".

I'm sort of a newbie and have a little problem understanding some of
the terms a read in other posts. Still don't know what DAO, stands
for.


Nov 12 '05 #2
Dee wrote:
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
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")
Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing

End Sub
The query returns only one field from one record of a table with 150
records. The field is a yes/no check field.

The query is a select query called "QrCheckDlrAssigned".
The field colums is name is "Dlr assigned".

I'm sort of a newbie and have a little problem understanding some of
the terms a read in other posts. Still don't know what DAO, stands
for.


I had this problem just 2 days ago. Exactly the same situation. Check
the query QrCheckDlrAssigned and there will be a criteria referring to
another field or form field ([forms]![myform]![id_field]). In my case
the query I was referring to had no criteria but the query it was based
on had a criteria. I had to delete the parameter 2 queries deep and it
ran straight away. I was really confused as the query would run normally.

Just try removing the criteria in the criteria and seeing if the code runs.

I have used some workarounds to eliminate this problem in the past. Let
me know and I will send them if you want. It involves reading the query
SQL into a string and adding the criteria by string manipulation.

If the query is used for nothing else you could put a token in the
criteria, say 123456, and then replace that token with the value you
have stored in a VBA variable. Have a look at http://www.mvps.org/access
in the Strings section for the Find and Replace function. Very useful.
Pass in three variables, the string being searched, the value to be
replaced and the value to replace it with.

HTH
Gavin
Nov 12 '05 #3
wo********@comcast.net (Dee) wrote in message news:<35**************************@posting.google. com>...
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
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")
Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing

End Sub
The query returns only one field from one record of a table with 150
records. The field is a yes/no check field.

The query is a select query called "QrCheckDlrAssigned".
The field colums is name is "Dlr assigned".

I'm sort of a newbie and have a little problem understanding some of
the terms a read in other posts. Still don't know what DAO, stands
for.


First off, could you post the SQL for QrCheckDlrAssigned?

Second, if the column name is Dlr assigned (no underscore) then
rs!Dlr_assigned will fail, because the names are different.

It is generally a Bad Thing to have spaces in column names. Use
PascalCase to name them - DlrAssigned. If you are stuck with that
column name you will need to replace:

rs!Dlr_assigned

with

rs![Dlr assigned]

HTH

Edward
--
The reading group's reading group:
http://www.bookgroup.org.uk
Nov 12 '05 #4
Dee,

Steve Jorgensen was correct!

Here's how you apply what he said ---

Dim db As DAO.Database
Dim qd As DAO.QueryDef

Dim Param As Parameter '<New>

Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")

' ------------New------------
For each Param in QD.Parameters
Param.Value = Eval(Param.Name)
Next Param
' -----------------------------

Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing



"Dee" <wo********@comcast.net> wrote in message
news:35**************************@posting.google.c om...
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
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("QrCheckDlrAssigned")
Set rs = qd.OpenRecordset()

If Not rs.EOF Then
Me!Terassigned = rs!Dlr_assigned
End If

On Error Resume Next
Set rs = Nothing
Set qd = Nothing
Set db = Nothing

End Sub
The query returns only one field from one record of a table with 150
records. The field is a yes/no check field.

The query is a select query called "QrCheckDlrAssigned".
The field colums is name is "Dlr assigned".

I'm sort of a newbie and have a little problem understanding some of
the terms a read in other posts. Still don't know what DAO, stands
for.

Nov 12 '05 #5
Still doesn't work.

"For Each Param In qd.Parameters" generates a type mismatch error.

By the way I changed the "Dlr assigned" field name to "Dlr_assigned".

Below is the sql for the query.

SELECT dealers5.Dlr_assigned
FROM dealers5
WHERE
(((dealers5.DlrId)=[Forms]![FmDealer5]![TerritoriesDescription].[Form]![
DealerID]));

The
")=[Forms]![FmDealer5]![TerritoriesDescription].[Form]![DealerID]))"
criteria is where I pass on the numeric long integer value I just
entered on one record of subform being displayed in datasheet view.

What I'm trying to do, is to check if the corresponding dealer is a
valid assigned dealer or just someone who is under consideration but has
not yet been approved.

Thanks for all the interest in helping me to try to solve this problem.

Dee
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #6
On 08 Jan 2004 22:39:38 GMT, Dee Simon <wo********@comcast.net> wrote:
Still doesn't work.

"For Each Param In qd.Parameters" generates a type mismatch error.


It probably was using the ADO implementation of Parameter. Try Dim Parameter
as DAO.Parameter. It's always best to specify ADO or DAO for -all-
declarations since there is so much overlap of class names between the two.
Nov 12 '05 #7
Yes that was it.

Thank you, Thank you, Thank you, Thank you, !!!!!

Thanks Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #8

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

Similar topics

2
by: Robert Mark Bram | last post by:
Hi All! My ASP page below receives the following error: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) Too few parameters. Expected 2. /polyprint/test.asp, line 31 ...
11
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>...
2
by: Susan Bricker | last post by:
Greetings Experts ... I have a routine that is invoked when a command button is clicked. The button is located in a form that is tied to a table of Project records. Each Project Record has 0 to...
8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
1
by: bonnie.tangyn | last post by:
Hello all I get Too few parameters expected 2 error and "The MS Jet Database engine cannot find the input table or query "myTempTablename". Make sure it exists and that its name is spelled...
2
by: Patrick Olurotimi Ige | last post by:
I converted the code below from VB.NET to C# cos i have to add it to a C# application!! But i'm getting the error:- System.Data.SqlClient.SqlCommand.Parameters' denotes a 'property' where a...
1
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,...
4
by: HeislerKurt | last post by:
I'm getting the infamous error, "Too few parameters. Expected 2", when executing an update SQL statement in VBA. I assume it's a SQL syntax issue, but I can't find the problem, and I used a VBA...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
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...
0
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...
0
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,...
0
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...
0
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...

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.