473,395 Members | 1,462 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,395 software developers and data experts.

Run time error - "Too Few parameters,Exception 1"

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 2019
Stewart Ross
2,545 Expert Mod 2GB
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
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...
6
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 ...
1
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...
1
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...
4
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...
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...
6
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...
3
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...
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...
1
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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:
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
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,...
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...
0
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...

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.