Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputting data from Form into Another Table 1

Status
Not open for further replies.

Stangleboy

Programmer
May 6, 2002
76
US
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
 
what are you trying to do i think that this will work
Code:
dim curDatabase as database
set curDatabase = currentdb
curDatabase.execute "insert into dbo_tbl_TransEmpCourse(EmpID,CourseID) values (" & Me!EmpID & "," & Me!Course& ")"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top