Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    48

    Unanswered: Not entering data in a form

    Hi,

    In a form, how can I make it that the user can't change the page without entering data into certain fields. If I enter is not null into the validation rule, it only works if the user first enters something, then deletes it. Is there a way to make it so that they have to enter something before they can click away from the record?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If by "can't change the page" you mean they can't go to another Record,
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)   
       If Nz(Me.Control1,"") = "" Then
         MsgBox "Control1 Must Not Be Left Blank!"
         Cancel = True
         Control1.SetFocus
         Exit Sub
       End If
       
      If Nz(Me.Control2, "") = "" Then
         MsgBox "Control2 Must Not Be Left Blank!"
         Cancel = True
         Control2.SetFocus
         Exit Sub
       End If
       
      End Sub
    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Sep 2011
    Posts
    48
    thanks!! Just one thing, after the message box pops up saying they can't go there and you click ok, it goes to a box saying "run-time error 424" Object required. How do I stop this from happening.

    Ohh Nevermind, I forgot to change the set.focus!

    Thanks!!!

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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