Number Error 3061
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have ms access runtime error 3061 too few parameters. expected 1 Meta Discuss the workings and policies of this site About Us
Run Time Error 3061 Too Few Parameters Expected 2
Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with run time error 3061 too few parameters expected 3 us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just
Too Few Parameters. Expected 1 Access
like you, helping each other. Join them; it only 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 run time error 3061 too few parameters expected 4 the fields from the table T:ActityRoster and the “Activity Date” from the form 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 d
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
Too Few Parameters. Expected 1 Excel
Learn more about Stack Overflow the company Business Learn more about hiring developers
Too Few Parameters Expected 1 Openrecordset
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack too few parameters. expected 3 access Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Too few parameters. Expected
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 http://stackoverflow.com/questions/22184774/access-run-time-error-3061-too-few-parameters-expected-1 Stack Overflow the company Business Learn more about hiring developers or posting ads with http://answers.microsoft.com/en-us/msoffice/forum/msoffice_access-mso_other/runtime-error-3061-too-few-parameters-expected-1/fd54064f-9f7f-4a3e-ac9b-1d27341883d6 us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Access Run-time error '3061': Too few parameters. Expected 1 up vote 1 down vote too few 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 put in the MsgBox just to verify it was picking up the correct value which it is. If I replace the too few parameters 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 4,2222137 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 = CurrentDb.OpenRecordset(lastAssignmentSQL, dbOpenDynaset, dbSeeChanges) ' ... As an additional precaution, if Forms!Details!ID is suposed to be a number (Integer or Long), I suggest you declare the variable CurAssetID explicitly: Dim curAssetID as Integer ' Or Long curAssetID = Forms!Details!ID Dim lastAssignment As DAO.Recor
be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 22 Oct 2016 00:06:10 GMT by s_nt6 (squid/3.5.20)