A
AnhCVL via AccessMonster.com
Hi all,
any suggestion on how to make this work:
Private Sub NEXT_Click()
On Error GoTo Exit_NEXT_Click:
If Nz(iSTATUS, "") = "" Then
MsgBox "Select a Status to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
iSTATUS.SetFocus
If Nz(iSTATUS, "") = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
Else
DoCmd.GoToRecord , , acNext
End If
Exit_NEXT_Click:
Exit Sub
End Sub
I have also tried this on the inner if loops:
If Nz(iSTATUS, "yes") = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
If iSTATUS.text = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
If iSTATUS.Value = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
"iStatus" is a combo box with dropdown selections with "yes" and "NO", and
"sDate" is a TexBox on the same form.
when I run the codes, the outer If loop work but it ignored the inner If loop
regardless of the value of "iStatus".
I am trying to get it to prompt user to enter a Date onto "sDate" field if
"iStatus" selection is "Yes" but the Textbox for "sDate" is empty when the
command button "NEXT" being clicked.
Thanks.
Mark
any suggestion on how to make this work:
Private Sub NEXT_Click()
On Error GoTo Exit_NEXT_Click:
If Nz(iSTATUS, "") = "" Then
MsgBox "Select a Status to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
iSTATUS.SetFocus
If Nz(iSTATUS, "") = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
Else
DoCmd.GoToRecord , , acNext
End If
Exit_NEXT_Click:
Exit Sub
End Sub
I have also tried this on the inner if loops:
If Nz(iSTATUS, "yes") = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
If iSTATUS.text = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
If iSTATUS.Value = "yes" And Nz(sDATE, "") = "" Then
MsgBox "Enter a valid Date to continue", vbOKOnly, "Missing Data"
DoCmd.CancelEvent
sDATE.SetFocus
End If
"iStatus" is a combo box with dropdown selections with "yes" and "NO", and
"sDate" is a TexBox on the same form.
when I run the codes, the outer If loop work but it ignored the inner If loop
regardless of the value of "iStatus".
I am trying to get it to prompt user to enter a Date onto "sDate" field if
"iStatus" selection is "Yes" but the Textbox for "sDate" is empty when the
command button "NEXT" being clicked.
Thanks.
Mark