Access Runtime Error 3061 Expected 2
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about ms access runtime error 3061 too few parameters. expected 2 hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask ms access runtime error 3061 too few parameters. expected 1 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
Runtime Error 3061 Expected 3
them; it only takes a minute: Sign up Error 3061 Too few parameters 2 expected up vote 1 down vote favorite I have been facing the error 3061 with error message "Too few Parameters: Expected 2". I have done
Run Time Error 3061 Expected 1
all of the following to resolve the issue but still couldn't it. I ran the query in SQL mode and it gives me result I checked all the field names I checked all the "&" s are placed. I find them correct. Here is my code: Private Sub cmbYear_Change() Dim db As Database Dim rs As DAO.Recordset Dim Query As String Query = " SELECT Yrs_Teaching, Highest_Edu, AD_Descr FROM ClassSurvey" & _ " WHERE ClassSurvey.Program/School_ID = " & ms access too few parameters. expected 2 Me.cmbProgId.Value & _ " AND ClassSurvey.ClassID = " & Me.cmbClassId.Value & _ " AND ClassSurvey.Teacher_ID = " & Me.cmbTeacherID.Value & _ " AND ClassSurvey.SYear = " & Me.cmbYear.Value Set db = CurrentDb Set rs = db.OpenRecordset(Query) If rs.RecordCount > 0 Then Me.TB1 = rs!Yrs_Teaching Me.TB2 = rs!Highest_Edu Me.TB3 = rs!AD_Descr Else Me.TB1 = "N/A" End If Set rs = Nothing Set db = Nothing End Sub ms-access access-vba share|improve this question edited Aug 29 '13 at 17:07 HansUp 79.1k114371 asked Aug 29 '13 at 16:33 user1804254 293411 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote It appears your table includes a field named Program/School_ID. Bracket that field name in the SELECT statement so the db engine can properly recognize it as one field name. That change might be all you need. But if you have another problem, give yourself an opportunity to examine the completed SELECT statement you're giving to the db engine. It might not be what you expect. Dim db As Database Dim rs As DAO.Recordset Dim strQuery As String strQuery = "SELECT cs.Yrs_Teaching, cs.Highest_Edu, cs.AD_Descr FROM ClassSurvey AS cs" & _ " WHERE cs.[Program/School_ID] = " & Me.cmbProgId.Value & _ " AND cs.ClassID = " & Me.cmbClassId.Value & _ " AND cs.Teacher_ID = " & Me.cmbTeacherID.Value & _ " AND cs.SYear = " & Me.cmbYear.Value Debug.Print strQuery Set db = CurrentDb Set rs = db.Open
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of
Run Time Error 3061 Too Few Parameters Expected 1
this site About Us Learn more about Stack Overflow the company Business vba too few parameters. expected 1 Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask too few parameters. expected 2 microsoft query 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 takes a minute: Sign up http://stackoverflow.com/questions/18516396/error-3061-too-few-parameters-2-expected Run-time error '3061'. Too few parameters. Expected 1. (Access 2007) up vote 5 down vote favorite I have the following 'set recordset' line that I cannot get working. The parameters seem correct according to all available help I can find on the subject. The error displays : "Run-time error '3061'. Too few parameters. Expected 1." Here is the line of code: Set rs http://stackoverflow.com/questions/5445062/run-time-error-3061-too-few-parameters-expected-1-access-2007 = dbs.OpenRecordset("SELECT Centre_X, Centre_Y FROM [qry_all_details] WHERE ID = " & siteID & ";", dbOpenSnapshot) Where rs is the recordset (Dim rs As Recordset) and dbs = CurrentDb() Any help would be appreciated. I have tried removing the WHERE cause with no effect, and also using single quotes between double quotes, but no joy. Many thanks. ms-access vba share|improve this question edited Mar 26 '11 at 20:31 gideon 15k54893 asked Mar 26 '11 at 20:23 uk52rob 26112 Is this query you're opening a parameterized one? Maybe it's expecting a value... –Tim Williams Mar 26 '11 at 20:35 1 Not sure if it's worth noting but your "one line" of code, at least as you entered it, is occupying two lines. Is that correct or is just the formatting here at SO? –Oneide Mar 26 '11 at 22:55 add a comment| 8 Answers 8 active oldest votes up vote 22 down vote "Run-time error '3061'. Too few parameters. Expected 1." I believe this happens when the field name(s) in your sql query do not match the table field name(s), i.e. a field name in
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox Videos Documentation Office Add-ins Office Add-in Availability Office Add-ins Changelog Microsoft Graph https://social.msdn.microsoft.com/Forums/office/en-US/556003a2-f970-4f6e-8bcc-9c8e73e25deb/run-time-error-3061-too-few-parameters-expected-2?forum=accessdev API Office 365 Connectors Office 365 REST APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Run time error 3061. Too few parameters. Expected 2. Microsoft Office for Developers > Access for Developers Question 0 Sign in to vote error 3061 It looks valid to me but for some reason I think I will need to change the syntax. Does anyone know what this should look like for Access 2007? Set rs = CurrentDb.OpenRecordset("select distinct report-period from Reports;") Wednesday, November 30, 2011 1:58 AM Reply | Quote Answers 1 Sign in to vote It looks valid to me but for some reason I think I will time error 3061 need to change the syntax. Does anyone know what this should look like for Access 2007? Set rs = CurrentDb.OpenRecordset("select distinct report-period from Reports;") Is "report-period" the name of a field? If so, the fact that it contains "punctuation" -- in this case, what looks to Access like a minus sign -- means you have to enclose it in square brackets: Set rs = CurrentDb.OpenRecordset("select distinct [report-period] from Reports") Otherwise, Access thinks that "report" and "period" are identifiers, and if they aren't fields in the Reports table then it figures they must be parameters. Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html Marked as answer by S.e.p.y Wednesday, November 30, 2011 2:46 AM Wednesday, November 30, 2011 2:22 AM Reply | Quote Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.Would you like to participate? Privacy statement Community Resources O365 Technical Network MSDN Forums UserVoice Stack Overflow Follow Us Twitter Facebook Office Dev Blog © 2016 Microsoft United States - English Terms of Use Trademarks Privacy Statement