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!

Missing Object 1

Status
Not open for further replies.

Stangleboy

Programmer
May 6, 2002
76
US
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
 
curDatabase.Execute "insert into dbo_tbl_TransEmpCourse(EmpID,CourseID) select EmpID,CourseID from tbl_TempAllEmployCourse"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I no longer get the error, but the CourseID is not populating the table.
 
Sorry, my table does not contain the CourseID field, that field is located on the form.
 
curDatabase.Execute "insert into dbo_tbl_TransEmpCourse(EmpID,CourseID) select EmpID," & Me!Course & " as CourseID from tbl_TempAllEmployCourse"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top