John,
What is the proper way to merge our codes?
Private Sub AddIncident_Click()
On Error GoTo Err_AddIncident_Click
Me!chkOKToClose = True
DoCmd.GoToRecord , , acNewRec
Exit_AddIncident_Click:
Exit Sub
Err_AddIncident_Click:
MsgBox Err.Description
Resume Exit_AddIncident_Click
End Sub
Private Sub Form_Current()
PreviousIncident.Enabled = Not Me.CurrentRecord = 1
NextIncident.Enabled = Not Me.CurrentRecord > Me.RecordsetClone.RecordCount
Me!chkOKToClose = False
End Sub
_________________________________________________
Your Close Button On Click:
Nope. That's not the Close Button On Click. That's the Form's BeforeUpdate
event. Just use both.
_________________________________________________
Private Sub Form_BeforeUpdate(Cancel as Integer)
Dim iAns As Integer
If Me!chkOKToClose = False Then
iAns = MsgBox("Please use the Add Incident button to save the record" _
& " or select Cancel to erase the form and start over", vbOKCancel)
Cancel = True ' cancel adding the record
If iAns = vbCancel Then
Me.Undo ' erase the form
End If
End If
End Sub
_________________________________________________
To my Close Button On Click:
Do you want the Close button to erase the contents of the form unless the
AddIncident button has been clicked? How do the two buttons interact for the
user?
_________________________________________________
Private Sub Close_Click()
On Error GoTo Err_Close_Click
Dim stDocName As String
Dim stLinkCriteria As String
If MsgBox("You will no longer be able to make changes to the Incident Log.
Are you sure you want to end this Incident Log Session?", vbQuestion +
vbYesNo, "Close Incident Log") = vbYes Then
DoCmd.Close
DoCmd.OpenForm "frmClosing", , , , acFormAdd
End If
Exit_Close_Click:
Exit Sub
Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click
End Sub
___________________________________________________
John W. Vinson [MVP]