In the form footer there are three command buttons: the first (“Clear This Timesheet”) clears the
timesheet so you can start over; the second (“Save This Timesheet”) saves the current timesheet
and starts a new record for entering another timesheet; and the third (“Send Timesheets to Excel”)
opens a dialog form listing the timesheets that have been completed for the current week, for
review. The three command button event procedures are listed as follows:
Private Sub cmdClearTimesheet_Click()On Error Resume NextDelete record in temp table:
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
Me![cboClientProject].RowSource = “”End SubPrivate Sub cmdSendToExcel_Click()On Error GoTo ErrorHandlerDoCmd.OpenForm FormName:=”fdlgTimesheets”
DoCmd.Close acForm, Me.NameErrorHandlerExit:
Exit SubErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExitEnd SubThe frmWeeklyTimesheet form is bound to a temp table, tblWeeklyTimesheetTemp, to ensure that
data won’t be saved to the regular table (tblWeeklyTimesheet) until the user chooses to save it, and
required fields have been filled in:
Private Sub cmdSaveTimesheet_Click()On Error GoTo ErrorHandlerCheck that required fields have values, and exit if not:
strTitle = “Value required”If Nz(Me![cboEmployeeID].Value) = “” Then
strPrompt = “Please select an employee”Working with Excel Worksheets 7