Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    EDIT CHECK (97/2)

    I have to do an edit check on a number of fields on a form. The form has alot of controls that can take you to other forms, close etc. I do not want to have to put the edit checks on each control. Where is the best place to put them so they will always edit.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: EDIT CHECK (97/2)

    If you want to validate the value of fields, you can use the Before Update event of the form. If a value does not conform to the requirements, set the Cancel argument of the event procedure to True. If you want to do something else, please explain.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: EDIT CHECK (97/2)

    The before update event works but I do not understand where to cancel the event. I have 5 different command buttons on the screen, each one does something different. Each one has to have the same edit check, which is handled in the before update event of the form but a cancel event in this edit check would not work for all 5 command buttons would it?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: EDIT CHECK (97/2)

    You could write a function in the form module that performs the check, and returns True if there is a problem, False otherwise. Say you name it EditCheck:

    Private Function EditCheck() As Boolean
    ...
    If ... Then EditCheck = True
    ...
    End Function

    In the Before Update event of the form, call it like this:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Cancel = EditCheck
    End Sub

    and in the On Click event procedures of the command buttons like this:

    Private Sub cmdSomething_Click()
    If EditCheck = True Then Exit Sub
    ' rest of the code goes here
    ...
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: EDIT CHECK (97/2)

    Thanks again for helping me. This works perfectly.

    Cathy

Posting Permissions

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