Stangleboy
Programmer
I must be tired and I am missing something in my code, the error I get is "Object Required" on the line. The code uses a form that runs a create table query "qry_SearchEmployees" to create "tbl_TempAllEmployCourse"; then I try to insert into another table the EmpID and CourseID (into "dbo_tbl_TransEmpCourse") from the temporary table, then I delete the table. Here is my code and thank you in advance for any assistance.
Private Sub bttn_AddEmployees_Click()
Dim curDatabase As Database
Set curDatabase = CurrentDb
DoCmd.OpenQuery "qry_SearchEmployees"
curDatabase.Execute "insert into dbo_tbl_TransEmpCourse(EmpID,CourseID) values (" & tbl_TempAllEmployCourse!EmpID & "," & Me!Course & ")"
DoCmd.DeleteObject acTable, "tbl_TempAllEmployCourse"
DoCmd.Beep
MsgBox ("The employees has been added to this record. Press the Refresh Employee List button at the top of the Course record to see addition.")
Me.EmpFunction = Null
Me.EmpTitle = Null
Me.EmpLoc = Null
End Sub
Private Sub bttn_AddEmployees_Click()
Dim curDatabase As Database
Set curDatabase = CurrentDb
DoCmd.OpenQuery "qry_SearchEmployees"
curDatabase.Execute "insert into dbo_tbl_TransEmpCourse(EmpID,CourseID) values (" & tbl_TempAllEmployCourse!EmpID & "," & Me!Course & ")"
DoCmd.DeleteObject acTable, "tbl_TempAllEmployCourse"
DoCmd.Beep
MsgBox ("The employees has been added to this record. Press the Refresh Employee List button at the top of the Course record to see addition.")
Me.EmpFunction = Null
Me.EmpTitle = Null
Me.EmpLoc = Null
End Sub