Cronk
Registered User.
- Local time
- Today, 21:45
- Joined
- Jul 4, 2013
- Messages
- 2,771
The code in #12 has issues. The line Cancel = true is not appropriate in a button Click event. Also, the form will be opened anyway as there is nothing to skip it should the control be blank.
Modified code
Modified code
Code:
Private Sub PreviewTearDown_Click()
If Me.Dirty Then Me.Dirty = False
If IsNull(Me![AFRNumber]) Then
' Alert the user.
MsgBox "You must enter an AFR Number."
' Cancel the update.
'--Cancel = True
Me.AFRNumber.SetFocus
exit sub
End If
Dim strDocName As String
Dim strWhere As String
strDocName = "Tear Down"
strWhere = "AFRsID=" & Me!AFRsID
DoCmd.OpenReport strDocName, acPreview, , strWhere
End Sub