A
awmohrjr
I have tried to develop code that would ensure that all fields on a
given form are completed before an action occurs. Unfortunately with
the code below I am able to create message boxes that display if the
field is empty, but the action still occurs. In other words, the even
is not cancelled if any fields are null on the form.
I would appreciate any help you could provide to correct this problem.
Thanks.
-----------------------------------------------------
Private Sub Command75_Click()
On Error GoTo Command75_Err
DoCmd.Echo True, ""
If (IsNull(Forms!frm_CFAAdd!Originator)) Then
Beep
MsgBox "The Originator must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!TechnicalContact)) Then
Beep
MsgBox "The Engr/PM must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!KAM)) Then
Beep
MsgBox "The KAM must be completed before proceeding.""",
vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Purpose)) Then
Beep
MsgBox "The Purpose must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CustID)) Then
Beep
MsgBox "The Customer must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Program)) Then
Beep
MsgBox "The Program must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Description)) Then
Beep
MsgBox "The Description must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!ExpandedDescr)) Then
Beep
MsgBox "The Expanded Description with Required Actions must
be completed before proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CustRefNo)) Then
Beep
MsgBox "The Customer RFQ No. must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!DrawingRef)) Then
Beep
MsgBox "The Drawing reference must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CADRef)) Then
Beep
MsgBox "The CAD reference must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!TypeofChange)) Then
Beep
MsgBox "The Type of Change must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
End If
[CFANo] = [CFA]
Forms!frm_CFAAdd.CFANo.Visible = True
Command75_Exit:
Exit Sub
Command75_Err:
MsgBox "All fields must be completed before proceeding.""",
vbOKOnly, "Action Stopped"
Resume Command75_Exit
End Sub
given form are completed before an action occurs. Unfortunately with
the code below I am able to create message boxes that display if the
field is empty, but the action still occurs. In other words, the even
is not cancelled if any fields are null on the form.
I would appreciate any help you could provide to correct this problem.
Thanks.
-----------------------------------------------------
Private Sub Command75_Click()
On Error GoTo Command75_Err
DoCmd.Echo True, ""
If (IsNull(Forms!frm_CFAAdd!Originator)) Then
Beep
MsgBox "The Originator must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!TechnicalContact)) Then
Beep
MsgBox "The Engr/PM must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!KAM)) Then
Beep
MsgBox "The KAM must be completed before proceeding.""",
vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Purpose)) Then
Beep
MsgBox "The Purpose must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CustID)) Then
Beep
MsgBox "The Customer must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Program)) Then
Beep
MsgBox "The Program must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!Description)) Then
Beep
MsgBox "The Description must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!ExpandedDescr)) Then
Beep
MsgBox "The Expanded Description with Required Actions must
be completed before proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CustRefNo)) Then
Beep
MsgBox "The Customer RFQ No. must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!DrawingRef)) Then
Beep
MsgBox "The Drawing reference must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!CADRef)) Then
Beep
MsgBox "The CAD reference must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
ElseIf (IsNull(Forms!frm_CFAAdd!TypeofChange)) Then
Beep
MsgBox "The Type of Change must be completed before
proceeding.""", vbOKOnly, "Action Stopped"
End If
[CFANo] = [CFA]
Forms!frm_CFAAdd.CFANo.Visible = True
Command75_Exit:
Exit Sub
Command75_Err:
MsgBox "All fields must be completed before proceeding.""",
vbOKOnly, "Action Stopped"
Resume Command75_Exit
End Sub