buratti
08-09-2009, 09:40 AM
I'm trying to... whenever a record is added to one table have it automatically add/append 3 fields from that record to another table. I tried making an apend query, but that copies all records from the source table. I just need the newly created record to be copied. I then tried VBA code from searching online, put it in the after update control of the form and came up with this, but it doesn't quite work.:
DoCmd.RunSQL "INSERT INTO EmployeeLog (EmployeeID, Work_Date, WorkCompleted) SELECT Me.EmployeeID, Me.Date_Off, Me.Reason"
I've tried variations of it like:
SELECT [Forms]![EmployeeDaysOffsubform]![Field1], [EmployeeID]![EmployeeDaysOffsubform]![Date_off],[Forms]![EmployeeDaysOffsubform]![Reason]
I dont know much about VBA... I can read most of it, but cant write it myself, and have no clue of the correct syntax when writing. Does anyone have suggestons on the correct code or other means of doing so? Also, is there a way to have it apend the records WITHOUT having the confirm dialog box appear before it runs?
Thanks for any help
BTW the table names are:
Source table: EmployeeDaysOff & EmployeeDaysOffsubform
Fields: EmployeeID, Date_Off, Reason
Destination table: Employee Log & EmployeeLogsubform
Fields: EmployeeID, Work_date, Workcompleted
DoCmd.RunSQL "INSERT INTO EmployeeLog (EmployeeID, Work_Date, WorkCompleted) SELECT Me.EmployeeID, Me.Date_Off, Me.Reason"
I've tried variations of it like:
SELECT [Forms]![EmployeeDaysOffsubform]![Field1], [EmployeeID]![EmployeeDaysOffsubform]![Date_off],[Forms]![EmployeeDaysOffsubform]![Reason]
I dont know much about VBA... I can read most of it, but cant write it myself, and have no clue of the correct syntax when writing. Does anyone have suggestons on the correct code or other means of doing so? Also, is there a way to have it apend the records WITHOUT having the confirm dialog box appear before it runs?
Thanks for any help
BTW the table names are:
Source table: EmployeeDaysOff & EmployeeDaysOffsubform
Fields: EmployeeID, Date_Off, Reason
Destination table: Employee Log & EmployeeLogsubform
Fields: EmployeeID, Work_date, Workcompleted