473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Filtering Recordset in MS Access-Run Time Error, Too Few Parameters!

10 New Member
Hi there,

I have a table [DailyUpdates] 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-[Description], and populate the resulting into textbox [FaultComms] of a form [UpdateSummary]

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim db As Database
  3. Dim rstUpdates As Recordset
  4.     Set db = CurrentDb
  5.     Set rstUpdates = db.OpenRecordset("Daily Fault Update", dbOpenDynaset)
  6. If Not rstUpdates.EOF Then rstUpdates.MoveFirst
  7. Do While Not rstUpdates.EOF
  8.     vntTempData = vntTempData & rstUpdates!Description
  9.     rstUpdates.MoveNext
  10. Loop
  11. Me.FaultComms = vntTempData
  12. End Sub
The problem I am having here is, this code gives data from all the records, I only need a filtered output. I tried to open the recordset based on query "Daily Fault Update Query" I end up with run time error '3061' -too few parameters expected 1.

I tried to use filter property of recordset to limit the records and then open another recordset on it. The second sample of code!
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim db As Database
  3. Dim vntTempData as Variant
  4. Dim rstUpdates As Recordset
  5. Dim rstUpdates1 As Recordset
  6. Dim strOpen As String
  7. strOpen= "[TT_Number] =[Forms]![TXFaults].[TT_Number]"
  8.     Set db = CurrentDb
  9.     Set rstUpdates = db.OpenRecordset("Daily Fault Update", dbOpenDynaset)
  10.     rstUpdates.Filter=strOpen
  11.     Set rstUpdates1= rstUpdates.OpenRecordset
  12. If Not rstUpdates1.EOF Then rstUpdates1.MoveFirst
  13. Do While Not rstUpdates1.EOF
  14.     vntTempData = vntTempData & rstUpdates1!Description
  15.     rstUpdates1.MoveNext
  16. Loop
  17. Me.FaultComms = vntTempData
  18. End Sub
I am also getting the rutime error too few parameters. Expected 3 on this line
Expand|Select|Wrap|Line Numbers
  1. Set rstUpdates1= rstUpdates.OpenRecordset
Jun 3 '08 #1
3 3820
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. An irritating change introduced in Access 2003 was that the default type of recordset (previously DAO) became the ADO version. As the call parameters of the OpenRecordSet and other methods differs slightly between versions run-time errors result when using the DAO syntax with what Access may presume is an ADO recordset. You should be able to resolve this by explicitly declaring the recordset variables as DAO recordsets:

Expand|Select|Wrap|Line Numbers
  1. Dim rstUpdates as DAO.RecordSet
  2. Dim rstUpdates1 as DAO.RecordSet
You will need to check that you have a reference to the DAO object library set - which you do from the VB editor window. Tools, References, make sure that Microsoft DAO 3.6 object library is ticked (or the nearest to it you have).

-Stewart
Jun 3 '08 #2
Kassimu
10 New Member
I am still getting the same error!
I remember to have read somewhere that One has to define Query parameter If I s/he has to use query as the base for the recordset.
How to do that?
Jun 3 '08 #3
Kassimu
10 New Member
I have got it sorted out! I changed the code to:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.    Dim vntTempData as Variant
  3.    Dim rstUpdates As DAO.Recordset
  4.    Set rstUpdates = CurrentDb.OpenRecordset("SELECT * FROM [Daily Fault Update] WHERE [TT_Number] = " & [Forms]![TXFaults].[TT_Number])
  5.    While Not rstUpdate.EOF
  6.       vntTempData = vntTempData & rstUpdates!Description
  7.       rstUpdates.MoveNext
  8.    Wend
  9.    Me.FaultComms = vntTempData
  10. End Sub
And it worked!
Jun 3 '08 #4

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

Similar topics

8
by: Tim Pollard | last post by:
Hi I am trying to filter a table of users to select only those records whose roleID matches a value in an array. There could be any number of IDs held in the array from one to a few hundred. The...
1
by: Aravind | last post by:
Hi folks. My database project has the following: -------------------------------------------------------------------------------- tables: Member: MemName, MemNo , MemType, CourseFaculty...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
2
by: Gerry Abbott | last post by:
Hi all. Im using a form's recordsource for a report. which works fine Me.RecordSource = Forms("frmdate01").Form.Controls("HoldLog").Form.Controls("frmHoldLog01").Form.RecordSource Ive got a...
3
by: Damon Grieves | last post by:
Hi I have a large table which I wanted to filter and then edit the selected record. I'm using a form with several pull down fields linked to lookup tables which correspond to fields in the large...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
1
by: Nicozz | last post by:
Hi, i working on an application based upon Access 2003. I have to fill a table with records resulting from the filtering of a simple form. Let's say i want to recover the whole records (let's...
0
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
0
by: Lyn | last post by:
I have a problem using the form .Filter and .FilterOn properties which causes Access to crash (as detailed in a separate post). The form operates in continuous mode, displaying matching records...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.