Error 3061 on attempted save

Status
Not open for further replies.

MayaMana

Registered User.
Local time
Yesterday, 22:50
Joined
May 29, 2012
Messages
60
Hi, I cannot figure out what I did but I assume it has something to do with an "if" "then" "elseif" statement I have on another part of the form.
I get the Run time error '3061' Too few parameters. Expected 1.

Set sn = db.OpenRecordset("SELECT * FROM TableName ORDER BY ID DESC", dbOpenDynaset, dbSeeChanges)

^is the line that I am getting the error message on. Everything I have found online so far deals with getting this message because of using a query which I don't think I am. :banghead:
If you need more of the code or have any questions as I'm not to sure how clear that was just ask. I would be grateful for any help/advice.

Thanks,
Mana
 
Is 3061 the parameters error? You're not using a query, so I'd double check the spelling of the table and field names. If that's not it, more of the code might help.
 
The save setup is exactly the same as I have it on my other databases so I'm not sure where I went wrong.

Private Sub Save_Click()
On Error GoTo ErrorHandler
Dim db As Database
Dim sn As Recordset

strCount = 0

If Me.txtPC >= 1 Then
If Not IsNull(Me.ChangeDate) Or Me.ChangeDate <> "" Then
'If you are adding a new record, then this code will work, if you finding an existing record you will need a where clause and an edit instead of addnew
Set db = CurrentDb
Set sn = db.OpenRecordset("SELECT * FROM ProcessChangeLog ORDER BY ID DESC", dbOpenDynaset, dbSeeChanges)

sn.AddNew
sn!PlantCode = Me.FullPCid
sn!ChangeDate = Me.ChangeDate
sn!Originator = Me.Initiator
sn!ProcessName = Me.ProcessNameCombo
sn!ProposedChange = Me.ProposedChange
sn!ExpectedResults = Me.ExpectedResults

'Updates and closes the record
sn.Update
sn.Close
End If
End If

'Clears the fields for the next entry
Me.PlantID = Null
Me.PCLID = Null
Me.FullPCid = Null
Me.ComboBoxPlant = Null
Me.ChangeDate = Null
Me.Initiator = Null
Me.ProcessNameCombo = Null
Me.ProposedChange = Null
Me.ExpectedResults = Null
Me.txtPC = Null

'Moves the cursor to this box
Me.Initiator.SetFocus


Exit_ErrorHandler:
Exit Sub

ErrorHandler:
MsgBox Err.Description
Resume Exit_ErrorHandler
End Sub
 
Last edited:
Is there a field in the table named "ID"? If not, there's your error. Based on what you're doing, you don't need the ORDER BY clause anyway, and you don't want to open the recordset with all records if all you're doing is adding a new record. You can use dbAppendOnly or:

Set sn = db.OpenRecordset("SELECT * FROM ProcessChangeLog WHERE 1=0", dbOpenDynaset, dbSeeChanges)
 
That makes sense. I forgot that the person who made the table change the regular ID to something else. Thank you.
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom