G
Guest
Hi. I am using 2003.
I need to test if a field is null. If it is, I need a message box to open
and ask if the field is supposed to be blank. The user can choose Yes or No.
This part is working OK.
The problem is: If the field should not be left blank and the user chooses
No, then I need the focus to return to the field in question. My code is not
capturing the answer from the message box. I have tried many different
methods........
My code is as follows:
Private Sub AOANumbers_Exit(Cancel As Integer)
On Error GoTo AOANumbers_Err
Dim Msg, Style, Title, Response
Msg = "Should the AOA Number be Blank?"
Style = vbYesNo + vbDefaultButton2
Title = "AOA Numbers"
If IsNull(AOANumbers) Then
Beep
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
Forms!frmDataEntryForm!AOANumbers.SetFocus
Else
Forms!frmDataEntryForm!strWGArea.SetFocus
End If
End If
AOANumbers_Exit:
Exit Sub
AOANumbers_Err:
MsgBox Error$
Resume AOANumbers_Exit
End Sub
If somebody could fix this for me, I would be extremely grateful.
TIA
I need to test if a field is null. If it is, I need a message box to open
and ask if the field is supposed to be blank. The user can choose Yes or No.
This part is working OK.
The problem is: If the field should not be left blank and the user chooses
No, then I need the focus to return to the field in question. My code is not
capturing the answer from the message box. I have tried many different
methods........
My code is as follows:
Private Sub AOANumbers_Exit(Cancel As Integer)
On Error GoTo AOANumbers_Err
Dim Msg, Style, Title, Response
Msg = "Should the AOA Number be Blank?"
Style = vbYesNo + vbDefaultButton2
Title = "AOA Numbers"
If IsNull(AOANumbers) Then
Beep
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
Forms!frmDataEntryForm!AOANumbers.SetFocus
Else
Forms!frmDataEntryForm!strWGArea.SetFocus
End If
End If
AOANumbers_Exit:
Exit Sub
AOANumbers_Err:
MsgBox Error$
Resume AOANumbers_Exit
End Sub
If somebody could fix this for me, I would be extremely grateful.
TIA