Access.2007.VBA.Bibl..

(John Hannent) #1
MsgBox prompt:=strPrompt, Buttons:=vbExclamation _
+ vbOKOnly, Title:=strTitle
Me![cboEmployeeID].SetFocus
GoTo ErrorHandlerExit
End If

If Nz(Me![cboClientProject].Value) = “” Then
strPrompt = “Please select a client and project”
MsgBox prompt:=strPrompt, Buttons:=vbExclamation _
+ vbOKOnly, Title:=strTitle
Me![cboClientProject].SetFocus
GoTo ErrorHandlerExit
End If

Save data from temp table to regular table:

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblWeeklyTimesheet”)
With rst
.AddNew
![EmployeeID] = Nz(Me![cboEmployeeID].Value)
![ClientCode] = Nz(Me![cboClientProject].Value)
![ProjectCode] = Nz(Me![txtProjectCode].Value)
![WeekEnding] = Nz(Me![txtWeekEnding].Value)
![ManagerID] = Nz(Me![cboEmployeeID].Column(2))
![MondayHours] = Nz(Me![txtMondayHours].Value)
![TuesdayHours] = Nz(Me![txtTuesdayHours].Value)
![WednesdayHours] = Nz(Me![txtWednesdayHours].Value)
![ThursdayHours] = Nz(Me![txtThursdayHours].Value)
![FridayHours] = Nz(Me![txtFridayHours].Value)
![SaturdayHours] = Nz(Me![txtSaturdayHours].Value)
![SundayHours] = Nz(Me![txtSundayHours].Value)
![MondayOTHours] = Nz(Me![txtMondayOTHours].Value)
![TuesdayOTHours] = Nz(Me![txtTuesdayOTHours].Value)
![WednesdayOTHours] = _
Nz(Me![txtWednesdayOTHours].Value)
![ThursdayOTHours] = Nz(Me![txtThursdayOTHours].Value)
![FridayOTHours] = Nz(Me![txtFridayOTHours].Value)
![SaturdayOTHours] = Nz(Me![txtSaturdayOTHours].Value)
![SundayOTHours] = Nz(Me![txtSundayOTHours].Value)
.Update
.Close
End With

Delete record in temp table:

DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf