I'm Stumped: Too Few Parameters Expected 1

tkepongo

Registered User.
Local time
Yesterday, 23:53
Joined
Jul 15, 2011
Messages
45
I am trying to retrieve text from a textbox and store it into a table. I am getting a Too Few Parameters error and I can't seem to find a way to fix it. I've tried all sorts of suggestions on Google but it doesn't seem to be working.

The problem occurs with the 'Audit_Scope' parameter. If I copy+paste the strSQL into SQL Server, it works perfectly. However, if I try to copy+paste it into Access Query, it keeps prompting me for the dbo_tbl_Audit.Audit_Scope.

Below are two different versions of the code that doesn't work :(

Code:
Private Sub btnUpdateScope_Click()
Dim Audit_ID As Variant
Dim Scope As Variant
Audit_ID = Me.Audit_ID
Scope = Forms!subfrmEditAudit.Audit_Scope
strSQL = "UPDATE dbo_tbl_Audit SET dbo_tbl_Audit.Audit_Scope= """ & Me.Audit_Scope & """ WHERE Audit_ID =  " & Audit_ID & ""
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError Or dbSeeChanges
MsgBox "The scope has been updated."
Me.Requery
End Sub

Code:
Private Sub btnUpdateScope_Click()
Dim Audit_ID As Variant
Dim Scope As Variant
Audit_ID = Me.Audit_ID
Scope = Me.Audit_Scope
strSQL = "UPDATE dbo_tbl_Audit SET dbo_tbl_Audit.Audit_Scope= '" & Scope & "' WHERE Audit_ID =  " & Audit_ID & ""
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError Or dbSeeChanges
MsgBox "The scope has been updated."
Me.Requery
End Sub
 
If it works in one and not the other, something is different between the two. Double check the table and field names on the Access side (the linked table name, which can be different than the name in SQL Server). Might one of the underscores be a space?
 
Problem Solved. Turns out I didn't refresh the linked table so the column didn't exist in the Access table. :o
 
Glad you got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom