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
Graeme Richardson - 18 Jan 2005 22:54 GMT
Hi, rather than set the focus back to the control, set the event's Cancel
argument to True.
If IsNull(AOANumbers) Then
Beep
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
Cancel = True
Else
Forms!frmDataEntryForm!strWGArea.SetFocus
End If
End If
HTH, Graeme.
CJ - 19 Jan 2005 00:43 GMT
Well.......wasn't that painless!!
Thanks very much Graeme
:-)
> Hi, rather than set the focus back to the control, set the event's Cancel
> argument to True.
[quoted text clipped - 10 lines]
>
> HTH, Graeme.