Access Run Time 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 hiring developers or access run time error 3061 too few parameters expected 1 posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join run time error 3061 expected 3 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 runtime error 3061 expected 1 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 all of the following to resolve
Run Time Error 3061 Too Few Parameters Expected 1
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 = " & Me.cmbProgId.Value & _ " AND ClassSurvey.ClassID = " & vba too few parameters. expected 1 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.OpenRecordset(strQuery) If you get an error, you can go to the Immediate window (Ctrl+g), copy the statement text fr
Search Community Links Social Groups Pictures & Albums Members List Calendar Search Forums Show Threads Show Posts Tag Search Advanced Search Find All Thanked Posts Go to Page... Page 1 of 2 1 2 > Thread Tools Rating: Display Modes 04-14-2003, 02:19 too few parameters. expected 2 microsoft query AM #1 Ally Newly Registered User Join Date: Sep 2001 Location: Colchester, Essex, England
Too Few Parameters. Expected 2 Excel
Posts: 617 Thanks: 0 Thanked 2 Times in 2 Posts Error 3061: Too Few Parameters. Expected 2 I have a form, which is opened
Ms Access Openrecordset Too Few Parameters Expected 2
from another form. When I try doing anything on the second form, I get the error message: Run-time error ‘3061’: Too few parameters. Expected 2 The code that is running is: Code: Private Sub ACPDailyDate_Exit(Cancel As Integer) Dim x, y, z http://stackoverflow.com/questions/18516396/error-3061-too-few-parameters-2-expected As String Dim r As Recordset, db As Database Dim DocName As String Dim LinkCriteria As String DocName = "frmACPData" Dim intNewRecord As Integer intNewRecord = IsNull(Me.ACPDailyID) Set db = CurrentDb() Set r = db.OpenRecordset("qryPtACPDaily") 'If intNewRecord Then Do Until r.EOF If r.Fields("acpdailydate") = Me.ACPDailyDate.Value Then msgbox r.Fields("PtFirstName") & " " & r.Fields ("PtLastName") & " already has ACP data for this date " & _ Chr(13) & r.Fields("acpdailydate"), vbOKOnly + vbExclamation, "Warning" DoCmd.Close Exit Sub ElseIf r.NoMatch Then End If r.MoveNext Loop http://www.access-programmers.co.uk/forums/showthread.php?t=45940 'Else Exit Sub 'End If Me.Refresh Exit Sub End Sub The line highlighted is: Set r = db.OpenRecordset("qryPtACPDaily") In the query there are 2 parameters: [Forms]![frmACPData]![EpisodeID] [Forms]![frmACPData]![UnitNo] The query runs fine on its own (when the form’s open). Does anyone know what’s wrong please? __________________ If you want to go to Heaven, you have to go via King's Cross! Not sure what to do with your old photos, or would like a special gift! To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. - UK Last edited by Ally; 04-14-2003 at 02:22 AM. Ally View Public Profile Find More Posts by Ally 04-14-2003, 02:33 AM #2 Mile-O Back once again... Join Date: Dec 2002 Location: Glasgow, UK Posts: 11,312 Thanks: 4 Thanked 112 Times in 107 Posts It would look like you are opening the query (via DAO) when it requires the parameters to open the query and, if the form is not open, it can't get to them. Keep the form frmACPData open, or if you don't want to see it set its Visible property to NO (at least that way it is still there and can be referenced. On another note, even though you didn't use the variables x, y, and z in that routine I just want to highlight something in case you don't know. Code: Dim x, y, z As String Will create
expected 2 If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before http://www.vbforums.com/showthread.php?707675-run-time-error-3061-too-few-parameters-expected-2 you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: run time error 3061 - too few parameters. expected 2 Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode too few Jan 26th, 2013,04:48 PM #1 Valerov View Profile View Forum Posts Thread Starter New Member Join Date Jan 2013 Posts 1 run time error 3061 - too few parameters. expected 2 hello everyone. im getting the error: "run time error 3061 - too few parameters. expected 2" when using a select query. i have the following code: dt.recordsource="Select * from Table_Name WHERE Field1 too few parameters like '" & combo1.text & "' AND Field2 like '" & combo2.text & "' AND Field3 like '" & combo3.text & "'" dt.refresh if i use the following, it works great: dt.recordsource="Select * from Table_Name WHERE Field1 like '" & combo1.text & "'" dt.refresh so i guess i use wrong syntax after 'WHERE' parameter. thanx in advance guyz Reply With Quote Jan 27th, 2013,05:44 AM #2 si_the_geek View Profile View Forum Posts Super Moderator Join Date Jul 2002 Location Bristol, UK Posts 38,273 Re: run time error 3061 - too few parameters. expected 2 Welcome to VBForums Thread moved from the 'CodeBank VB6' forum (which is for you to post working code examples, not questions) to the 'Database Development' forum... the 'VB6 and earlier' forum would be the place if it wasn't covered by a more specific forum Your syntax is basically good, so there are several potential causes for the error, including: * The simplest is that you may have typed one of the field names wrong. * One of the field names might not be safe. For more information (including lists of Reserved words), see the art