473,770 Members | 6,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run time error - "Too Few parameters,Exce ption 1"

1 New Member
Expand|Select|Wrap|Line Numbers
  1. Dim cstsname As String
  2. Dim cstpc As String
  3.  
  4. Dim rstresult As Recordset 'recordset to store output
  5. Dim mydatabase As Database
  6.  
  7. 'Variable to store user entered surname
  8. Me.Text20.SetFocus
  9. cstsname = Text20.Text
  10.  
  11. 'Variable to store user entered postcode
  12. Me.Text22.SetFocus
  13. cstpc = Text22.Text
  14.  
  15. 'sql statement to select from customer table
  16.  
  17. Set mydatabase = CurrentDb
  18.  
  19. Set rstresult = mydatabase.OpenRecordset( _
  20. "SELECT CustomerID, CustomerForename, CustomerSurname, CstPostcode FROM tblcustomer WHERE CustomerSurname = '" & cstsname & "' AND CustPostcode = '" & cstpc & "'", dbOpenDynaset, dbReadOnly)
I am trying to use the select statement to retrieve the matching record from a table of customers details and output them to a list box. I keep getting "Too few parameters, Exception 1". I am using variables as can be seen from the code above and not directly referenceing objects on the Microsoft access form. Any suggestions.
Sep 25 '08 #1
1 2034
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi, and Welcome to Bytes!

There are two different kinds of recordsets which can be used - ADO, which is generally more suited for applications outside of Access that need to refer to tables via the JET database engine (or via connections to client-server databases such as SQL Server), and DAO, the native Access recordset type.

Their methods have different definitions and arguments.

In Access 2003 the default type changed to the slightly different ADO from the native DAO recordsets, leading to confusing error messages like the one you have mentioned.

To resolve this change your definition of rstresult to qualify it with the DAO type:

DIM rstresult as DAO.Recordset

To use DAO recordsets you must also ensure that there is a reference to the Microsoft DAO 3.X object library in your project references. From the VB editor select Tools, References and ensure that the latest version is ticked if it is not currently ticked, otherwise you will find the compiler generates a syntax error on the qualified declaration.

-Stewart

ps the actual error message is "too few parameters, expected 1" (not exception 1)
Sep 25 '08 #2

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

Similar topics

5
6383
by: Csaba Gabor | last post by:
The usual example shown for trapping for failure of COM instantiation (Windows systems) is something like (see for example http://at2.php.net/manual/en/class.com.php): $word = new COM("word.application") or die("Unable to instantiate Word"); This is all well and good, but if you are using a command line interface (CLI) version of PHP 5 then you might wish to have a little more sophisticated error handling. Specifically,
6
6120
by: Tony | last post by:
Dear All, When I run an example program on the http://www.dotnetjunkies.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/data/datagrid1.src&file=VB\datagrid1.aspx&font=3 I received an error message: "The ConnectionString property has not been initialized.
1
1977
by: Dale | last post by:
Access 2003 frt end attached to sql 2000 backend I am trying to check for an existing record but cannot get past this error, too few parameters, expected 2 I have verified that all fields exist and tested the query. It appears to occur on the Set Rec Line
1
3546
by: vsen123 | last post by:
hi I got this error: "Divide-error Exception 0x3D27:0x14D3 Resumable Processor Fault" in Turbo C++ 4.5(Win 16) in a program that uses multi-level Inheritance. The problem occurs when I try to create an object of the last derived class(found out using trace).All the derived classes are derived using public visibility mode. Code snippet: class Finale:public R_mov { int PC2,Key_t,t_cnt; protected: int Key_final; public:
4
12936
by: Daniel Guettler | last post by:
I'm getting lots of "Error: too much recursion" in my Firefox Error Console I have created these little files to test it. It justs opens a new window and closes it again. I see plenty of errors showing up in the Error Console The main file: <html> <body>
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:
6
2463
by: Matsam | last post by:
Hi, I am using ADODB connection in ASP and want to run a select query depending on a runtime criteria. But its not working and giving error "Too few parameters. Expected 1." But the same thing is working when pasted in Access query. The problem comes when including a LIKE criteria. can anybody help me ?? Matsam
3
8607
by: dilipdafda | last post by:
Hi all, I do not have the idea how could I get the backend error/exception message into forms6i application? I used RAISE_APPLICATION_ERROR(error_number, error_text) in DB table's trigger, I want the message in my front-end. However, I am getting the error that Oracle unable to insert and on pressing shift + F1 I am getting the message that I wrote in DB. But I want it as an alert. and can I give yes-no type alert there? for example
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...
1
13740
by: jimgym1989 | last post by:
I dont get it..why is the error: Exception in thread "main" java.util.InputMismatchException this is my code /** * @(#)textFileRead.java * * * @author * @version 1.00 2008/10/17 */
0
9592
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
9425
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
10059
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
10005
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
9871
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...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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.