T
tlynn
I currently have a data entry from only set up with a “Confirm†button that
the person must press after data has been entered to check that the required
data has been into the form. For the confirm button to work each of the
required fields is tagged with an “Râ€. They then must press either a
“Submit†button to save the entered data and print a report of the data just
entered, or press the “Cancel†to delete the data an close the form.
I would like to change this process to have a “Yes†or “No†prompt box
appear after the person presses a “Confirm†button, to respond to the
question “Save this Report?.†With the current process, people are
forgetting to press either the “Submit†or “Cancel†buttons.
Any other ideas/options would also be appreciated:
The “Confirm†buttons “On Click†code is:
Private Sub VERIFY_BUTTON_Click()
AllowSave = True
Me.Dirty = False
DoCmd.Close
End Sub
The Forms “Before Update†code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "R" Then
If Nz(ctl.Value) = 0 Then
MsgBox "The " & ctl.Name & " field is required. Please enter
a value."
ctl.SetFocus
Exit For
End If
End If
Next ctl
If AllowSave Then
AllowSave = False
Else
Me.Undo
Cancel = True
End If
End Sub
The “Submit†buttons “On Click†code is:
Private Sub SAVE_BUTTON_Click()
On Error GoTo Err_SAVE_BUTTON_Click
Dim strDocName As String
Dim StrWhere As String
strDocName = "Q-NMR Report"
StrWhere = "[ID]=" & Me!ID
DoCmd.OpenReport strDocName, acPrint, , StrWhere
DoCmd.Close
Exit_SAVE_BUTTON_Click:
Exit Sub
Err_SAVE_BUTTON_Click:
MsgBox Err.DESCRIPTION
Resume Exit_SAVE_BUTTON_Click
End Sub
The “Cancel†buttons “On Click†code is:
Private Sub ERASE_BUTTON_Click()
On Error GoTo Err_ERASE_BUTTON_Click
If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
DoCmd.Close
Exit_ERASE_BUTTON_Click:
Exit Sub
Err_ERASE_BUTTON_Click:
MsgBox Err.DESCRIPTION
Resume Exit_ERASE_BUTTON_Click
End Sub
the person must press after data has been entered to check that the required
data has been into the form. For the confirm button to work each of the
required fields is tagged with an “Râ€. They then must press either a
“Submit†button to save the entered data and print a report of the data just
entered, or press the “Cancel†to delete the data an close the form.
I would like to change this process to have a “Yes†or “No†prompt box
appear after the person presses a “Confirm†button, to respond to the
question “Save this Report?.†With the current process, people are
forgetting to press either the “Submit†or “Cancel†buttons.
Any other ideas/options would also be appreciated:
The “Confirm†buttons “On Click†code is:
Private Sub VERIFY_BUTTON_Click()
AllowSave = True
Me.Dirty = False
DoCmd.Close
End Sub
The Forms “Before Update†code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "R" Then
If Nz(ctl.Value) = 0 Then
MsgBox "The " & ctl.Name & " field is required. Please enter
a value."
ctl.SetFocus
Exit For
End If
End If
Next ctl
If AllowSave Then
AllowSave = False
Else
Me.Undo
Cancel = True
End If
End Sub
The “Submit†buttons “On Click†code is:
Private Sub SAVE_BUTTON_Click()
On Error GoTo Err_SAVE_BUTTON_Click
Dim strDocName As String
Dim StrWhere As String
strDocName = "Q-NMR Report"
StrWhere = "[ID]=" & Me!ID
DoCmd.OpenReport strDocName, acPrint, , StrWhere
DoCmd.Close
Exit_SAVE_BUTTON_Click:
Exit Sub
Err_SAVE_BUTTON_Click:
MsgBox Err.DESCRIPTION
Resume Exit_SAVE_BUTTON_Click
End Sub
The “Cancel†buttons “On Click†code is:
Private Sub ERASE_BUTTON_Click()
On Error GoTo Err_ERASE_BUTTON_Click
If Me.Dirty Then
Me.Undo
End If
If Not Me.NewRecord Then
RunCommand acCmdDeleteRecord
End If
DoCmd.Close
Exit_ERASE_BUTTON_Click:
Exit Sub
Err_ERASE_BUTTON_Click:
MsgBox Err.DESCRIPTION
Resume Exit_ERASE_BUTTON_Click
End Sub