harleyskater
IT Manager
- Local time
- Yesterday, 23:20
- Joined
- Oct 29, 2007
- Messages
- 95
I have a timeclock that I built into my access program. That just allows employees to clockin and out. I needed to ask how to automatically through VBA when a form is closed from a click of the [X] in the upper right hand corner how to cancel the changes that are waiting to be updated in the DB. This is the code I have so far, but this is more for the button I have in my form the "clockin button" that updates the record with the information. I want to be able to allow the person to hit the X and exit the form with no prompts and no updates. This is the code I have so far.
So what I am hoping for is a code that cancels the update from the exit or close trigger that skips the beforeupdate trigger all together. Any suggestions? !: ) : )
So what I am hoping for is a code that cancels the update from the exit or close trigger that skips the beforeupdate trigger all together. Any suggestions? !: ) : )
Code:
Option Compare Database
Dim LTotal As Long
Private Sub Command15_Click()
DoCmd.Close
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
LTotal = DCount("emp_id", "employee clockin Query", "emp_id = " & emp_id & "") ' if 1+ already clocked in
If LTotal > 0 Then
MsgBox "You have not Clocked Out " & emp_first & "", _
vbExclamation, "Please ClockOut."
Cancel = True
Exit Sub
End If
lngAnswr = MsgBox("Is your Entry Correct " & emp_first & "?", vbOKCancel + vbQuestion)
If lngAnswr = vbOK Then
Cancel = False
MsgBox ("ClockIn Confirmed " & emp_first & "")
Else ' User chose No.
Cancel = True
MsgBox ("ClockIn Canceled " & emp_first & "")
End If
End Sub