Stangleboy
Programmer
I am using a form to input data into another table. I wrote VBA code and yesterday it worked fine but when I closed everything out I think the code decompiled or something else changed my settings. I am now getting the error "Run-time error '3622': You must use the dbSeeChanges option with Openrecordset when accessing a SQL Server table that has an IDENTITY column". I add the dbSeeChanges and then get another error "Invalid operation". Any help would be great, I posted me code below, my insert table is "dbo_tbl_TransEmpCourse". I want to thank everyone in advance for their time.
Private Sub bttn_AddEmplCourse_Click()
Dim curDatabase As Object
Dim dbo_tbl_TransEmpCourse As Object
Set curDatabase = CurrentDb
Set dbo_tbl_TransEmpCourse = curDatabase.OpenRecordset("dbo_tbl_TransEmpCourse", dbOpenTable, dbSeeChanges)
dbo_tbl_TransEmpCourse.AddNew
dbo_tbl_TransEmpCourse("EmpID").Value = Me!EmpID
dbo_tbl_TransEmpCourse("CourseID").Value = Me!Course
dbo_tbl_TransEmpCourse.Update
Set dbo_tbl_TransEmpCourse = Nothing
Set curDatabase = Nothing
DoCmd.Beep
If MsgBox("Employee has been added to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
Private Sub bttn_AddEmplCourse_Click()
Dim curDatabase As Object
Dim dbo_tbl_TransEmpCourse As Object
Set curDatabase = CurrentDb
Set dbo_tbl_TransEmpCourse = curDatabase.OpenRecordset("dbo_tbl_TransEmpCourse", dbOpenTable, dbSeeChanges)
dbo_tbl_TransEmpCourse.AddNew
dbo_tbl_TransEmpCourse("EmpID").Value = Me!EmpID
dbo_tbl_TransEmpCourse("CourseID").Value = Me!Course
dbo_tbl_TransEmpCourse.Update
Set dbo_tbl_TransEmpCourse = Nothing
Set curDatabase = Nothing
DoCmd.Beep
If MsgBox("Employee has been added to this record." _
& vbCrLf & vbCrLf & "Do you want to save these changes?" _
, vbYesNo, "Changes Made...") = vbYes Then
DoCmd.Save
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub