Can not update table

S

scuba79

I'm trying to update a field of a specific record via a command button.
However, I keep getting an error message stating "invalid operation".

Here is the code that I'm using with the command button.

Private Sub btnApplyInterviewer_Click()

Dim dbs As Database, rst As DAO.Recordset, strSql As String

On Error GoTo btnApplyInterviewer_Err

strSql = "UPDATE Rating SET InterviewerID = " &
cboNewInterviewer.Value & " WHERE RatingID = " & NotesMod.SignalID


Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)

btnApplyInterviewer_Exit:
If Not rst Is Nothing Then rst.Close
If Not dbs Is Nothing Then dbs.Close
Exit Sub
btnApplyInterviewer_Err:
MsgBox Err.Description
Resume btnApplyInterviewer_Exit

Any assistance in pointing me in the right direction is greatly appreciated.
 
R

Ron Weiner

Scuba

You are working to hard! You do not want to open a Recordset, you simple
want to execute an update query.

Private Sub btnApplyInterviewer_Click()
Dim strSql As String

strSql = "UPDATE Rating SET InterviewerID = " &
cboNewInterviewer.Value & " WHERE RatingID = " & NotesMod.SignalID
DoCmd.SetWarnings False
DoCmd.RunSql strSql
DoCmd.SetWarnings True
End Sub

Ron W

scuba79 said:
I'm trying to update a field of a specific record via a command button.
However, I keep getting an error message stating "invalid operation".

Here is the code that I'm using with the command button.

Private Sub btnApplyInterviewer_Click()

Dim dbs As Database, rst As DAO.Recordset, strSql As String

On Error GoTo btnApplyInterviewer_Err

strSql = "UPDATE Rating SET InterviewerID = " &
cboNewInterviewer.Value & " WHERE RatingID = " & NotesMod.SignalID


Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)

btnApplyInterviewer_Exit:
If Not rst Is Nothing Then rst.Close
If Not dbs Is Nothing Then dbs.Close
Exit Sub
btnApplyInterviewer_Err:
MsgBox Err.Description
Resume btnApplyInterviewer_Exit

Any assistance in pointing me in the right direction is greatly
appreciated.
 
S

scuba79

Thanks Ron.

Ron Weiner said:
Scuba

You are working to hard! You do not want to open a Recordset, you simple
want to execute an update query.

Private Sub btnApplyInterviewer_Click()
Dim strSql As String

strSql = "UPDATE Rating SET InterviewerID = " &
cboNewInterviewer.Value & " WHERE RatingID = " & NotesMod.SignalID
DoCmd.SetWarnings False
DoCmd.RunSql strSql
DoCmd.SetWarnings True
End Sub

Ron W


appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top