473,789 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_AfterU pdate()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("Q rCheckDlrAssign ed")
Set rs = qd.OpenRecordse t()

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 "QrCheckDlrAssi gned".
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 9480
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********@comc ast.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_AfterU pdate()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("Q rCheckDlrAssign ed")
Set rs = qd.OpenRecordse t()

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 "QrCheckDlrAssi gned".
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_AfterU pdate()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("Q rCheckDlrAssign ed")
Set rs = qd.OpenRecordse t()

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 "QrCheckDlrAssi gned".
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 QrCheckDlrAssig ned 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********@comc ast.net (Dee) wrote in message news:<35******* *************** ****@posting.go ogle.com>...
Running an AfterUpdate event procedure, I get the following error:

"Too few parameters. Expected 1."

My code is as follows:
Private Sub DealerID_AfterU pdate()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("Q rCheckDlrAssign ed")
Set rs = qd.OpenRecordse t()

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 "QrCheckDlrAssi gned".
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 QrCheckDlrAssig ned?

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("Q rCheckDlrAssign ed")

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

Set rs = qd.OpenRecordse t()

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********@com cast.net> wrote in message
news:35******** *************** ***@posting.goo gle.com...
Running an AfterUpdate event procedure, I get the following error:

"Too few parameters. Expected 1."

My code is as follows:
Private Sub DealerID_AfterU pdate()

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Set db = CurrentDb
Set qd = db.QueryDefs("Q rCheckDlrAssign ed")
Set rs = qd.OpenRecordse t()

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 "QrCheckDlrAssi gned".
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_assign ed".

Below is the sql for the query.

SELECT dealers5.Dlr_as signed
FROM dealers5
WHERE
(((dealers5.Dlr Id)=[Forms]![FmDealer5]![TerritoriesDesc ription].[Form]![
DealerID]));

The
")=[Forms]![FmDealer5]![TerritoriesDesc ription].[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********@com cast.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
6726
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 Line 31 is this line from below:
11
3044
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'...
2
1917
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 many Task Records associated with it (in another table). I want to 'logically remove' the Project Record and all Task Records for the Project (by setting the field in each of those records to 'true'). Here is the problem ... in the routine I...
8
11242
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 update 3 row(s)." Is there a way to prevent the message from popping up?
1
2888
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 correctly. 3078" after I migrated "MS Access 2000" to "MS SQL Server 2000" and relinked all linked tables. The front-end interface of my application is MS Access 2000. The back-end is MS SQL Server 2000. After I migrated the database and
2
6672
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 'method' was expected At the lines:- myCommand.Parameters("@Username").Value = strLogonUsr;
1
22307
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
4
10686
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 generator to generate the SQL statement. Debugging points to this line: dbs.Execute strSQl, dbFailOnError Here's the code:
3
3834
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...
0
9665
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
9511
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
10408
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
10199
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
10139
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
5417
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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
3
2909
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.