Access 2007 Runtime Error 3061 Too Few Parameters
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
Ms Access Runtime Error 3061 Too Few Parameters. Expected 2
Us Learn more about Stack Overflow the company Business Learn more about hiring runtime error 3061 too few parameters expected 1 developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the access run time error 3061 too few parameters expected 1 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 Run-time error '3061'. Too few parameters.
Run Time Error 3061 Too Few Parameters Expected 2
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 = dbs.OpenRecordset("SELECT Centre_X, Centre_Y FROM [qry_all_details] WHERE ID = "
Too Few Parameters. Expected 1 Access
& 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 the query is wrong or perhaps the table is missing the field altogether. share|improve this answer answered Dec 9 '11 at
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 too few parameters. expected 1 openrecordset this site About Us Learn more about Stack Overflow the company Business Learn
Too Few Parameters. Expected 1 Excel
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question run time error 3061 too few parameters expected 3 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 Access http://stackoverflow.com/questions/5445062/run-time-error-3061-too-few-parameters-expected-1-access-2007 Run-time error '3061': Too few parameters. Expected 1 up vote 1 down vote favorite I'm getting an Access Run-time error: '3061': Too few parameters. Expected 1 when trying to run some VBA code from a form with sub-report. I've tried with the variable (CurAssetID) as well as the direct link (Forms!Details!ID) in the SQL query but both result in the same error. I http://stackoverflow.com/questions/22184774/access-run-time-error-3061-too-few-parameters-expected-1 put in the MsgBox just to verify it was picking up the correct value which it is. If I replace the last part of the SQL query with a value (HAVING (((Assignments.AssetID)=1));") it works fine. What's going on here and how can I fix it? Private Sub LineSelect_Click() CurAssetID = Forms!Details!ID Status = MsgBox(CurAssetID, vbOKOnly) Dim LastAssignment As DAO.Recordset LastAssignmentSQL = "SELECT Assignments.AssetID, Last(Assignments.LocationID) AS LastLocationID FROM Assignments GROUP BY Assignments.AssetID HAVING (((Assignments.AssetID)=CurAssetID));" Set LastAssignment = CurrentDb.OpenRecordset(LastAssignmentSQL, dbOpenDynaset, dbSeeChanges) sql vba ms-access share|improve this question edited Mar 5 '14 at 1:40 Yawar 3,9162034 asked Mar 4 '14 at 22:43 user3377449 8113 Your SQL can't see your VBA parameters. –ta.speot.is Mar 4 '14 at 22:48 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted You can create a string variable with the parameter value concatenated inside it: curAssetID = Forms!Details!ID status = MsgBox(CurAssetID, vbOKOnly) Dim lastAssignment As DAO.Recordset lastAssignmentSQL = "SELECT Assignments.AssetID, " & _ "Last(Assignments.LocationID) AS LastLocationID " & _ "FROM Assignments " & _ "GROUP BY Assignments.AssetID " & _ "HAVING (((Assignments.AssetID)=" & CurAssetID & "));" Set lastAssignment = C
Ask a Question Need help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. It's quick & easy. in DAO: Run time error 3061 Too few parameters.... https://bytes.com/topic/access/answers/660221-dao-run-time-error-3061-too-few-parameters P: n/a Richard Hollenbeck I wonder what I'm missing? I really feel like a retard because I've been 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 too few = CurrentDb Set rs = 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 too few parameters report it runs fine. Jun 10 '07 #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"