Error 3061 Access
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and ms access run time error 3061 too few parameters policies of this site About Us Learn more about Stack Overflow the
Ms Access Runtime Error 3061 Too Few Parameters. Expected 1
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags error 3601 too few parameters Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only access error 3061 expected 2 takes a minute: Sign up Why Run-time error '3061'. Too few parameters. Expected 1? Access 2010 up vote 1 down vote favorite I have researched all the STACKOVERFLOW questions on this but cannot make it work. I have a simple table: And a form: I want to extract the fields from the table T:ActityRoster and the “Activity Date” from the form
Access Error 3021
and “add” them to a table T:ActivityHistory. A STACKOVERFLOW expert helped me with some code, but it won’t even set the first recordset:rsIn Dim ActID As Integer, actDate As Date, val1 As Long, val2 As Long, val3 As Boolean, val4 As Currency Dim db As Database, rsIn As Recordset, rsOut As Recordset Dim strSQL As String Set db = CurrentDb ActID = Me.cboActivityName.Column(0) strSQL = "SELECT * FROM T:ActivityRoster WHERE [ActivityID] = ActID" Debug.Print strSQL Set rsIn = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly) rsIn.MoveLast Set rsOut = db.OpenRecordset("T:AttendanceHistory", dbOpenDynaset, dbEditAdd) rsOut.MoveLast actDate = Me.ActivityDate.Value ' retrive the date from the form With rsIn .MoveFirst Do val1 = !ActivityID val2 = !MemberID val3 = !Attended val4 = !AmtSpent With rsOut .AddNew !ActivityDate = actDate !ActivityID = val1 !MemberID = val2 !Attended = val3 !AmtSpent = val4 .Update End With .MoveNext Loop Until .EOF .Close End With rsOut.Close Set rsIn = Nothing Set rsOut = Nothing Set db = Nothing End Sub I have verified that all field names are correct and are consistent data types. When I put the query back into Acce
be down. Please try the request again. Your cache administrator is webmaster. Generated Tue, 11 Oct 2016 08:48:06 GMT by s_wx1131 (squid/3.5.20)
Ask a Question Need help? Post your question and get tips & solutions from a community of 418,509 IT Pros & Developers. It's quick & easy. in DAO: Run time error 3061 Too few parameters.... P: n/a Richard https://bytes.com/topic/access/answers/660221-dao-run-time-error-3061-too-few-parameters Hollenbeck I wonder what I'm missing? I really feel like a retard because I've been http://vbcity.com/forums/t/167850.aspx screwing with some code for a very long time. I just must be missing something very simple. In the following example, I've stripped away everything that doesn't cause the error to make my question a little simpler. Here's the problem in its simplest form inside a report: Dim db As DAO.Database Dim rs As DAO.RecordSet Set db = CurrentDb Set rs = error 3061 db.OpenRecordset("SELECT * FROM qryTableOfGrades") 'where qryTableOfGrades is a saved crosstab query. I get "Run time error 3061 Too few parameters. Expected 0." but if I just make that last line: Set rs = db.OpenRecordset("qryTableOfGrades") I get "Run time error 3061 Too few parameters. Expected 1." And if I do this: Set rs = db.OpenRecordset(qryTableOfGrades) ' without quotes I get "variable not defined." If I run the query by itself without the report it runs fine. Jun 10 '07 too few parameters #1 Post Reply Share this Question 1 Reply P: n/a Allen Browne There is a name in qryTableOfGrades that Access cannot resolve to a field name, so it interprets it as a parameter. The parameter could be several things, e.g.: a) Something like this: [Forms].[Form1].[Text22] When you run the query, the Expression Service handles that reference. But the ES is not available in DAO code, so it is treated as an unsupplied parameter. b) A misspelled field name. c) A field name in the Filter or Order By properties of the query, if the field no longer exists. You should be able to identify what the parameter is by closing all forms, running the query, and seeing what name it asks for. It is possible to supply the parameter programmatically, e.g.: Dim qdf As DAO.QueryDef Set qdf = dbEngine(0)(0).QueryDef("qryTableOfGrades") qdf.Parameters("[Forms].[Form1].[Text22]") = [Forms].[Form1].[Text22] Set rs = qdf.OpenRecordset(... -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Richard Hollenbeck"
'3061': Too few parameters. Expected 1. rated by 0 users This post has 1 verified answer | 1 Reply | 1 Follower Suggest an Answer Reply wheels Scarborough, Maine Since 7/27/2002 Posts 793 Reputation 13,635 DAVE (wheels) posted on 10/30/2013 9:55 AM rated by 0 users Good afternoon. I am trying to execute a query to fill a text field on an Access report, and I am getting the run-time error. I have the following code that works fine: Dim db As DAO.Database Dim rs As DAO.Recordset Dim myArray() As Variant, i As Long Dim strSQL As String, strHighPriorityIDs As String, strStartDate As Date, strEndDate As Date i = 1 Set db = CurrentDb strStartDate = [Forms]![Rpt_Options]![txtStartDate].Value strEndDate = [Forms]![Rpt_Options]![txtEndDate].Value strSQL = "SELECT [Feedback Form].ID FROM [Feedback Form] WHERE ([Feedback Form].Priority='High' AND [Feedback Form].Date Between #" & strStartDate & "# And #" & strEndDate & "#)" Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot) However when I use the following strSQL code it fails with the parameter error: strSQL = "SELECT [Client Services/CMT GOS Feedback Form].ID From [Client Services/CMT GOS Feedback Form] WHERE ([Forms]![Rpt_Options]![cboBizArea]='Core Market' AND [Client Services/CMT GOS Feedback Form].[Core Marketing Feedback Source] Is Not Null AND [Client Services/CMT GOS Feedback Form].Priority='High' AND ([Client Services/CMT GOS Feedback Form].Date Between #" & strStartDate & "# AND #" & strEndDate & "#)) OR ([Forms]![Rpt_Options]![cboBizArea]='NCG' AND [Client Services/CMT GOS Feedback Form].[NCG Feedback Source] Is Not Null AND [Client Services/CMT GOS Feedback Form].Priority='High' AND ([Client Services/CMT GOS Feedback Form].Date Between #" & strStartDate & "# AND #" & strEndDate & "#))" Also if I just reference the query (which works when I run directly), I get an Run-time error '3061': Too few parameters. Expected 3 I am using the same code as above, but the rs is set as follows: Set rs = db.OpenRecordset("qryHighPriorityIDs", dbOpenSnapshot) Very odd and frustrating. A second pair of eyes would be welcome and helpful. I would appreciate any insgiht anyone may have. Thank you, WHEELS Filed under: MS Office, Access, VBA, Windows 7 | Post Points: 5 Verified Answer wheels Scarborough, Maine Since 7/27/2002 Posts 793 Reputation 13,635 Reply DAVE (wheels) replied on 10/30/2013 11:22 AM rated by 0 users Verified by DAVE (wheels) [Forms]![Rpt_Options]![cboBizArea].Value I FINALLY figured it out. It appears the dynamic SQL didn't like referencing the