Update Query giving me a runtime error 3061 (1 Viewer)

spnz

Registered User.
Local time
Today, 07:05
Joined
Feb 28, 2005
Messages
84
Hi there....Im busy tonight trying to get a couple of things working correctly.

I have an UPDATE string that I am trying to get working but I am getting a runtime error 3061 saying 'To few parameters Expected 1'

I have tried the same query using the query builder and it works ok...when I try it in VBA it doesn't work.

This is my code
Code:
Dim SQLUpdate As String
Dim SQLWhere As String
Dim strComplete As String
       

SQLUpdate = " UPDATE tblPersonalInformation SET tblPersonalInformation.DateModified = Now() "
SQLWhere = " WHERE tblPersonalInformation.PersonalID = [Forms]![frmMain]![txtCandidateNumberReadOnly]"



strComplete = SQLUpdate & SQLWhere
Debug.Print strComplete
      
   
        CurrentDb.Execute strComplete
End Sub

Can anyone see what I am missing or I am doing wrong?


Thanks evryone for your help.
 

Alex McDevitt

Registered User.
Local time
Today, 07:05
Joined
Nov 12, 2002
Messages
28
Try....

SQLWhere = " WHERE tblPersonalInformation.PersonalID = " & Forms!frmMain!txtCandidateNumberReadOnly & ";"
 

spnz

Registered User.
Local time
Today, 07:05
Joined
Feb 28, 2005
Messages
84
Thanks Alex that worked great.
 

spnz

Registered User.
Local time
Today, 07:05
Joined
Feb 28, 2005
Messages
84
Its me again.

I have tired using the same code on a different event and I am getting the same error code.

Code:
Private Sub Form_AfterInsert()
 
     
    Dim strPersonalID As String
    Dim strInsertedBy As String
    Dim SQLUpdate As String
    Dim SQLWhere As String
    Dim strComplete As String
    
    strPersonalID = Me.txtPersonalID
    strInsertedBy = Me.txtLoginName
  
    SQLUpdate = " UPDATE tblPersonalInformation SET tblPersonalInformation.Addedby = strInsertedBy "
    SQLWhere = " WHERE tblPersonalInformation.PersonalID = " & Forms!frmMain!txtCandidateNumberReadOnly & ";"
    
    Debug.Print SQLUpdate & SQLWhere
   
   ''Need to ensure that directory already exists or will go into debug
   MkDir "C:\Temp Information\" & CStr([txtTempName])
  
 
    strComplete = SQLUpdate & SQLWhere
    CurrentDb.Execute strComplete

End Sub
I only made small changes but now its not working. Is it because the strInsertedBy is a text string?

PLease help!!!

Thank you
 

RV

Registered User.
Local time
Today, 07:05
Joined
Feb 8, 2002
Messages
1,115
Yep, should be:

Code:
SQLUpdate = " UPDATE tblPersonalInformation SET tblPersonalInformation.Addedby = '" &strInsertedBy & "'"

RV
 

spnz

Registered User.
Local time
Today, 07:05
Joined
Feb 28, 2005
Messages
84
Thanks for your prompt reply RV.
 

Users who are viewing this thread

Top Bottom