473,387 Members | 1,530 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.

Recordset object issues and 'too few parameters'

I am very much a novice and would greatly value any input on this issue. I had written a function which was an absolute parallel construction to the one listed below, but this one keeps giving me 'two few parameters. Expected 2' error in the immediate window. I have looked very carefully at the WHERE statement in the immediate window (debugging) and I cannot see any error. With further debugging attempts, it keeps sending me to this line: Set rt = dc.OpenRecordset(strsqli). Here is the complete code for the function:

Expand|Select|Wrap|Line Numbers
  1. Function arrears(longID As Long, strID As String)
  2.  
  3.  
  4.  
  5. Dim rt As DAO.Recordset
  6. Dim startArrears As Currency
  7. Dim dc As DAO.Database
  8. Dim strsqli As String
  9.  
  10. Set dc = CurrentDb
  11.  
  12.  
  13.  strsqli = "SELECT tlbstartArrears.personID, tlbstartArrears.unitID, tlbstartArrears.startBalance AS starting " & _
  14. "FROM tlbstartArrears " & _
  15. "WHERE (((tblstartArrears.personID)=" & longID & ")" & "AND" & "((tblstartArrears.strID)='" & strID & "'" & "));"
  16.  
  17. Set rt = dc.OpenRecordset(strsqli)
  18. startArrears = rt!starting
  19.  
  20. arrears = startArrears
  21.  
  22. rt.Close
  23. dc.Close
  24. Set rt = Nothing
  25. Set dc = Nothing
I have a feeling that the bang operator is not being used correctly. The sql string is just about identical in form the other function where it works perfectly. I am not experienced enough with recordsets to quite figure this one out. Please help!
Jul 31 '14 #1

✓ answered by twinnyfo

First, please use the Code tags when posting code, so it is easier for us to follow.

Second, right before the line that gives you the error, insert:

Expand|Select|Wrap|Line Numbers
  1. Debug.Print strsqli
Then post what is listed int he immediate window. This will help us debug what is wrong with your string.

However, one problem might be iwth your "AND"

It should probably be:

Expand|Select|Wrap|Line Numbers
  1. & " AND " &
Note the spaces around the keyword.

4 991
twinnyfo
3,653 Expert Mod 2GB
First, please use the Code tags when posting code, so it is easier for us to follow.

Second, right before the line that gives you the error, insert:

Expand|Select|Wrap|Line Numbers
  1. Debug.Print strsqli
Then post what is listed int he immediate window. This will help us debug what is wrong with your string.

However, one problem might be iwth your "AND"

It should probably be:

Expand|Select|Wrap|Line Numbers
  1. & " AND " &
Note the spaces around the keyword.
Jul 31 '14 #2
To twinnyfo,

I really appreciate input on this issue; I think that I did figure this one out! I am not sure how to use code tags feature. I presume it is the [code/] button. I will try it out.
Jul 31 '14 #3
zmbd
5,501 Expert Mod 4TB
feature. I presume it is the [code/] button. I will try it out.
Yes that the ticket (^_^)

Simply click on the [CODE/] button in the post toolbar and then cut and paste your script between the [code] [/code] tags.

This link will provide some general hints on how to setup your VBA-Editor, basic troubleshooting, and how to post your formated text and scripts.
Jul 31 '14 #4
Thank you zmbd and others; this is finally coming along better. I am sure that from a design point of view, this database project is crude compared to those of professional developers, but it manages to do the trick so far.Seem to be getting the hang of sql syntax also. Evidently, a fair number of 'novices' are trying there hand at writing a database and injecting code for more customized performance.
Aug 1 '14 #5

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

Similar topics

4
by: Thomas Scheiderich | last post by:
Why would you use the Recordset object over the Execute method of getting data from your Sql database. For example, I have the following: Execute Method...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
4
by: gman997 | last post by:
Hi all, At a high level here is what is going on -- I built a C# COM object. I need to call this com object from SQL Server using the sp_OACreate stored procedure in SQL Server. I build the COM...
3
by: JingleBEV | last post by:
Hi all, I am trying not to use global variable to maintain data consistency. Some procedures and functions will require to pass the recordset object for processing and functions may also return...
1
by: Bala A | last post by:
I have an ActiveX EXE. One of the methods in this component has "Recordset Object" as input parameter which has to be passed by reference. I have to call this method from C# code. From C#, how...
6
by: rob | last post by:
Dear All, I have a COM+ component that returns an ADODB.Recordset. In an include file that is included by an aspx page I assign that returned recorset to an ADODB._Recordset. Unfortunately, this...
1
by: munusoni | last post by:
Hi everyone, i am using ASP 3.0 to create web pages for a college project and i am having problems in using recordset object through session object to pass data to all web pages.Anyone tell me how...
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
18
reginaldmerritt
by: reginaldmerritt | last post by:
When opeing and closing a DAO recordset a few times i get the following error message: I've been google and forum investigating all day. The only thing i have found is information on...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.