473,508 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DAO Recordset from Select Query - Runtime 3061 - Too Few Parameters. Expected 1.

9 New Member
Hi

I am trying to update a recordset, however, I cannot get the code to run as i get Runtime Error: 3061. Too Few Parameters. Expected 1. Line 6 is highlighted when you debug. Any assistance would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1. Sub CalcLoop()
  2.  
  3. Dim db As DAO.Database
  4. Dim rs As DAO.Recordset
  5. Set db = CurrentDb
  6. Set rs = db.OpenRecordset("qry_FleetRS", dbOpenDynaset)
  7.  
  8. rs.MoveFirst
  9.  
  10. Do While Not rs.EOF
  11.  
  12. rs.MoveNext
  13. Loop
  14.  
  15. Call FleetCalc
  16.  
  17. rs.Close
  18.  
  19. Set rs = Nothing
  20. Set db = Nothing
  21.  
  22. End Sub
  23.  
  24.  
May 2 '13 #1
8 4480
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
It sounds like there might be an error in the SQL of qry_FleetRS. Does the query run without problems if you open it manually?
May 2 '13 #2
Viv Jones
9 New Member
Hi,

Yes it does. The underlying query is selecting all fields from a table where one field is equal to a field on an open form.

Thanks
Viv
May 2 '13 #3
Viv Jones
9 New Member
Here is the query in SQL

Expand|Select|Wrap|Line Numbers
  1. SELECT tbl_NCBCalcs.QuoteID, tbl_NCBCalcs.REGISTRATIONNO, tbl_NCBCalcs.NCBE1, tbl_NCBCalcs.NCBE2, tbl_NCBCalcs.NCBE3, tbl_NCBCalcs.NCBE4, tbl_NCBCalcs.NCBE5, tbl_NCBCalcs.StartingNCB, tbl_NCBCalcs.POIS1, tbl_NCBCalcs.POIE1, tbl_NCBCalcs.IAF1F, tbl_NCBCalcs.POIS2, tbl_NCBCalcs.POIE2, tbl_NCBCalcs.IAF2F, tbl_NCBCalcs.POIS3, tbl_NCBCalcs.POIE3, tbl_NCBCalcs.IAF3F, tbl_NCBCalcs.POIS4, tbl_NCBCalcs.POIE4, tbl_NCBCalcs.IAF4F, tbl_NCBCalcs.POIS5, tbl_NCBCalcs.POIE5, tbl_NCBCalcs.IAF5F, tbl_NCBCalcs.StartPOI1, tbl_NCBCalcs.StartPOI2, tbl_NCBCalcs.StartPOI3, tbl_NCBCalcs.StartPOI4, tbl_NCBCalcs.StartPOI5, tbl_NCBCalcs.PercentageE1, tbl_NCBCalcs.PercentageE2, tbl_NCBCalcs.PercentageE3, tbl_NCBCalcs.PercentageE4, tbl_NCBCalcs.PercentageE5, tbl_NCBCalcs.StartPOIDate, tbl_NCBCalcs.StartPOI6, tbl_NCBCalcs.NCBID
  2. FROM tbl_NCBCalcs
  3. WHERE (((tbl_NCBCalcs.QuoteID)=[Forms]![frm_Fleet]![QuoteID]));
  4.  
May 2 '13 #4
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I don't often use form references in query, so I am a bit rusty in that regard.

What happens if you try:
Expand|Select|Wrap|Line Numbers
  1. Sub CalcLoop()
  2.  
  3. Dim db As DAO.Database
  4. Dim rs As DAO.Recordset
  5. dim lngQuoteID as long
  6. lngQuoteID=Forms!frm_Fleet!QuoteID
  7. Set db = CurrentDb
  8. Dim strSQL as string
  9. strSQL="SELECT tbl_NCBCalcs.QuoteID, tbl_NCBCalcs.REGISTRATIONNO, tbl_NCBCalcs.NCBE1, tbl_NCBCalcs.NCBE2, tbl_NCBCalcs.NCBE3, tbl_NCBCalcs.NCBE4, tbl_NCBCalcs.NCBE5, tbl_NCBCalcs.StartingNCB, tbl_NCBCalcs.POIS1, tbl_NCBCalcs.POIE1, tbl_NCBCalcs.IAF1F, tbl_NCBCalcs.POIS2, tbl_NCBCalcs.POIE2, tbl_NCBCalcs.IAF2F, tbl_NCBCalcs.POIS3, tbl_NCBCalcs.POIE3, tbl_NCBCalcs.IAF3F, tbl_NCBCalcs.POIS4, tbl_NCBCalcs.POIE4, tbl_NCBCalcs.IAF4F, tbl_NCBCalcs.POIS5, tbl_NCBCalcs.POIE5, tbl_NCBCalcs.IAF5F, tbl_NCBCalcs.StartPOI1, tbl_NCBCalcs.StartPOI2, tbl_NCBCalcs.StartPOI3, tbl_NCBCalcs.StartPOI4, tbl_NCBCalcs.StartPOI5, tbl_NCBCalcs.PercentageE1, tbl_NCBCalcs.PercentageE2, tbl_NCBCalcs.PercentageE3, tbl_NCBCalcs.PercentageE4, tbl_NCBCalcs.PercentageE5, tbl_NCBCalcs.StartPOIDate, tbl_NCBCalcs.StartPOI6, tbl_NCBCalcs.NCBID " & _
  10.      " FROM tbl_NCBCalcs " & _
  11.      " WHERE (((tbl_NCBCalcs.QuoteID)=" & lngQuoteID & "));
  12. Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  13.  
  14. rs.MoveFirst
  15.  
  16. Do While Not rs.EOF
  17.  
  18. rs.MoveNext
  19. Loop
  20.  
  21. Call FleetCalc
  22.  
  23. rs.Close
  24.  
  25. Set rs = Nothing
  26. Set db = Nothing
  27.  
  28. End Sub
May 2 '13 #5
Viv Jones
9 New Member
Hi

That works, insofar as it no longer gives me the parameter error, however it is not looping through and updating all records. It only updates the first record and then stops.

Any suggestions?
May 2 '13 #6
Stewart Ross
2,545 Recognized Expert Moderator Specialist
You have a loop which is not doing anything at all at present

Expand|Select|Wrap|Line Numbers
  1. Do While Not rs.EOF
  2.  rs.MoveNext
  3. Loop
  4.  
This just loops to the end of file. You have not posted the Update part of your code / SQL; I presume that it's done by the Call Fleetcalc line (line 21 in your original post).

Shouldn't that call be within the loop? I cannot be sure about this, as if you have reached the end of file any call afterwards is surely invalid, but as you have not posted the relevant section it's hard to know for sure.

-Stewart
May 3 '13 #7
Viv Jones
9 New Member
Thanks Stewart,

I just cannot seem to get it to move to the next record and perform the updates.

I have a query set up which retrieves the same records as the SQlStr in my code, and this query is returning the correct number of records.

I have not posted the code for Sub FleetCalc, as this in turn runs a number of update queries and calls other procedures dependant on which conditions are true for a particular record.

I have amended my code (below), which is updating perfectly on the first record in the recordset. Any further suggestions would be welcomed. I am no expert, so any assistance is greatly appreciated.


Expand|Select|Wrap|Line Numbers
  1. Sub CalcLoop()
  2.  
  3. Dim db As DAO.Database
  4. Dim rs As DAO.Recordset
  5. Dim lngQuoteID As Integer
  6.  
  7. lngQuoteID = Me!QuoteID
  8. 'QuoteID = Me.QuoteID
  9.  
  10. Set db = CurrentDb
  11.  
  12. Dim strSQL As String
  13.  
  14. strSQL = "SELECT tbl_NCBCalcs.QuoteID, tbl_NCBCalcs.REGISTRATIONNO, tbl_NCBCalcs.NCBE1, tbl_NCBCalcs.NCBE2, tbl_NCBCalcs.NCBE3, tbl_NCBCalcs.NCBE4, tbl_NCBCalcs.NCBE5, tbl_NCBCalcs.StartingNCB, tbl_NCBCalcs.POIS1, tbl_NCBCalcs.POIE1, tbl_NCBCalcs.IAF1F, tbl_NCBCalcs.POIS2, tbl_NCBCalcs.POIE2, tbl_NCBCalcs.IAF2F, tbl_NCBCalcs.POIS3, tbl_NCBCalcs.POIE3, tbl_NCBCalcs.IAF3F, tbl_NCBCalcs.POIS4, tbl_NCBCalcs.POIE4, tbl_NCBCalcs.IAF4F, tbl_NCBCalcs.POIS5, tbl_NCBCalcs.POIE5, tbl_NCBCalcs.IAF5F, tbl_NCBCalcs.StartPOI1, tbl_NCBCalcs.StartPOI2, tbl_NCBCalcs.StartPOI3, tbl_NCBCalcs.StartPOI4, tbl_NCBCalcs.StartPOI5, tbl_NCBCalcs.PercentageE1, tbl_NCBCalcs.PercentageE2, tbl_NCBCalcs.PercentageE3, tbl_NCBCalcs.PercentageE4, tbl_NCBCalcs.PercentageE5, tbl_NCBCalcs.StartPOIDate, tbl_NCBCalcs.StartPOI6, tbl_NCBCalcs.NCBID " & _
  15.      " FROM tbl_NCBCalcs " & _
  16.      " WHERE (((tbl_NCBCalcs.QuoteID)=" & lngQuoteID & "));"
  17.  
  18. Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
  19.  
  20. rs.MoveFirst
  21.  
  22. Do Until rs.EOF
  23.  
  24.     Call FleetCalc  'Calls multiple procedures and queries to update almost every field in the recordset, dependant on a range of conditions.
  25.  
  26.     rs.MoveNext
  27.  
  28. Loop
  29.  
  30. rs.Close
  31.  
  32. Set rs = Nothing
  33. Set db = Nothing
  34.  
  35. End Sub
  36.  
May 5 '13 #8
Viv Jones
9 New Member
Thanks Stewart and TheSmileyCoder.

Without your assistance I would not have made it this far.

I have managed to resolve the last problem. It appears that I was dealing with a .EOF issue. I still have one more error to fix, and once complete I will post the final working code.
May 6 '13 #9

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

Similar topics

8
1902
by: kbrad | last post by:
I am using the following code in asp to select some data from an access db. recSel is defined and set further up my webpage, as is rsUpdate User. I cannot work out how to get past this error...
7
9467
by: Dee | last post by:
Running an AfterUpdate event procedure, I get the following error: "Too few parameters. Expected 1." My code is as follows: Private Sub DealerID_AfterUpdate() Dim db As DAO.Database
4
7155
by: Richard Hollenbeck | last post by:
I thought I was very specific in this SQL request. There is a form open with a selected record (and a corresponding "lngRecipeID" on that form. The table also has a field called "lngRecipeID". ...
1
1827
by: javediq143 | last post by:
Hi all, I got one more prob in another ASP page linked to the earlier one. I've created an Access DB and created a query using Access Query wizard. The query is running fine in Access and it is...
6
5306
by: Nano | last post by:
I have created ASP file from MS Access. It has the following Code. But it gives an error at: rs.Open sql, conn, 3, 3 The Error is: Error Type: Microsoft OLE DB Provider for ODBC Drivers...
3
4376
by: phill86 | last post by:
Hi, I am trying to run the following query in a recordset and i get the following error message Runtime error 3061 - Too few parameters. Expected 1 i am using the following code
8
2972
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1....
12
1699
by: hannoudw | last post by:
I tried to figure out what i did wrong, and i couldn't find the mistake could any one help me ?? i'm getting this message :Error 3061, Too few parameters Expected 1. achat_num and fact_num are both...
6
12400
by: dowlingm815 | last post by:
I am receiving error code too few parameters. Expected 1. I can't seem to find the issue. The error code occurs when on this line of code: Set rstTemp =...
4
3922
by: shalskedar | last post by:
In my DB(Ms Access 2003)I want to delete a record from 1 table which is linked to another table. For ex- There are 2 tables "MasterType" which is the Master table & another table as "Sash DO"...
0
7133
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
7405
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
7504
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...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
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
3214
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
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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
435
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...

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.