G
Guest
I have entered an if statement with a msgbox if the value of a text field is
outside of a specified range (between 0.5 and 5.0) and the memo box
"Corrective Action Taken" is null. The msgbox is working, but as soon as you
press OK on it, the form closes. What I need for it to do is set the focus
back on the memo box "Corrective Action Taken" and not close the form until
the criterion is met.
My code is as follows:
Private Sub Closecmd_4_Mill_Click()
On Error GoTo Err_Closecmd_4_Mill_Click
If ((Stack_No_18_Air < 0.5) Or (Stack_No_18_Air > 5#)) And
(Stack_No_18_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_18_Action.SetFocus
End If
If ((Stack_No_16_Air < 0.5) Or (Stack_No_16_Air > 5#)) And
(Stack_No_16_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_16_Action.SetFocus
End If
If ((Stack_No_17_Air < 0.5) Or (Stack_No_17_Air > 5#)) And
(Stack_No_17_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_17_Action.SetFocus
Else
DoCmd.Close
End If
Exit_Closecmd_4_Mill_Click:
Exit Sub
Err_Closecmd_4_Mill_Click:
MsgBox Err.Description
Resume Exit_Closecmd_4_Mill_Click
End Sub
Thank you in advance for your help!
outside of a specified range (between 0.5 and 5.0) and the memo box
"Corrective Action Taken" is null. The msgbox is working, but as soon as you
press OK on it, the form closes. What I need for it to do is set the focus
back on the memo box "Corrective Action Taken" and not close the form until
the criterion is met.
My code is as follows:
Private Sub Closecmd_4_Mill_Click()
On Error GoTo Err_Closecmd_4_Mill_Click
If ((Stack_No_18_Air < 0.5) Or (Stack_No_18_Air > 5#)) And
(Stack_No_18_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_18_Action.SetFocus
End If
If ((Stack_No_16_Air < 0.5) Or (Stack_No_16_Air > 5#)) And
(Stack_No_16_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_16_Action.SetFocus
End If
If ((Stack_No_17_Air < 0.5) Or (Stack_No_17_Air > 5#)) And
(Stack_No_17_Action = "") Then
MsgBox "Corrective Action must be entered if reading is less than 0.5 or
greater than 5.0."
Closecmd_4_Mill.Enabled = False
Stack_No_17_Action.SetFocus
Else
DoCmd.Close
End If
Exit_Closecmd_4_Mill_Click:
Exit Sub
Err_Closecmd_4_Mill_Click:
MsgBox Err.Description
Resume Exit_Closecmd_4_Mill_Click
End Sub
Thank you in advance for your help!