Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Gloucestershire, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    alerting re required fields (Access 2000)

    I have several fields which are required - but my form does not shout at you until you try to go on to the next record. I would like to be able to alert people as soon as they leave the text box that they should have put something in and not let them proceed until they have!

    I have tried to think of some suitable validation - but am not having much luck.

    Thanks

  2. #2
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: alerting re required fields (Access 2000)

    The first thing that comes to mind (not necessarily the best) ... On the OnExit event of each of these textboxes, you could check for IsNull, display a MsgBox stating the field is required, and return the cursor to the textbox.

    Alternately, you could write it more globally and call it from the appropriate textboxes.

    If you need assistance writing the code, post again.
    HTH

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Gloucestershire, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: alerting re required fields (Access 2000)

    a bit of code would be much appreciated. As I am not sure how the syntax would go.

    Thanks for your assistance

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: alerting re required fields (Access 2000)

    In the On exit of the textbox:
    <pre>Private Sub txtField_Exit(Cancel As Integer)
    If IsNull(Me!txtField) Then
    MsgBox "You have to enter something in this field"
    Cancel = True
    End If
    End Sub
    </pre>

    Francois

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: alerting re required fields (Access 2000)

    One warning about using the OnExit code that the others mentioned. That'll work if you're tabbing from one field to the next, but the OnExit code won't stop you from skipping fields entirely using the mouse.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •