Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    New Hampshire Coast
    Posts
    18

    Unhappy Unanswered: Field Retains focus on null

    Hi,
    I have a database which is populated with data from another database. The records are then edited by the end-user in a data-entry form.

    I'm trying create a control on a forum whereas the user isn't able to proceed if the value is null.

    I've written code like this:
    If IsNull(Forms![Census Tracking]!DateReferredUW) = True Then
    MsgBox "Please Enter a Value"
    Forms!DateReferredUW.SetFocus
    End If

    I get the message box to come up, but the user is allowed to go to the next field after clicking "OK" on the message box.

    How can I get the field to retain focus? A loop of some sort?

  2. #2
    Join Date
    May 2004
    Posts
    6
    In which event did you put the code?

  3. #3
    Join Date
    Mar 2004
    Location
    New Hampshire Coast
    Posts
    18
    I've tried it on "BeforeUpdate" and "OnExit"

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Use the on Exit event

    Private Sub txt_Para1_Exit(Cancel As Integer)
    If IsNull(txt_Para1) Then
    Cancel = 1
    End If
    End Sub

  5. #5
    Join Date
    Mar 2004
    Location
    New Hampshire Coast
    Posts
    18
    this is exactly what i needed it to do! thank you so much.

Posting Permissions

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