Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2005

Tip: Looking for answers? Try searching our database.

Test for field content not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
CJ - 18 Jan 2005 21:21 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.