Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297

    Question Unanswered: On Change for entire form???

    Guess who's back, back again...

    Hi all,

    Bit more bother, should be easy to fix, just can't seem to work it out...

    I have a form, which has various inputs, which are all fine.

    Problem is, I have a submit button, that I only want to be visible/clickable/whatever, when all of the inputs have a value. I can't for the life of me find out how to get the form to monitor for changes.

    I've tried using Form_AfterUpdate(), but it won't even display:

    Code:
    MsgBox "Test"
    When I put it in there... Is there something I'm missing? Or another alternative?

    The code I was using in the Form_AfterUpdate() was:

    Code:
    If ((Me.baseColSelect.Value = "") Or _
        (Me.trimColSelect.Value = "") Or (Me.sizeInput.Value = "") Or _
        (Me.typeSelect.Value = "")) Then
            rdyToSubmit = False
    Else
            rdyToSubmit = True
    End If
    MsgBox "Test"
    Which didn't do anything. I also changed the form property 'After Update' to '[Event procedure]', still with no luck.

    Any help, or workarounds, would be greatly appreciated!

    Thanks all.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you may have to place some code behind each control in the on change event and or on lost focus event

    the process could be
    set the submit button to disabled or invisible in the on current event.. your call
    create a function which enables or makes visible assuming there's no errors
    for each control that MUST have a value place some code behind that that calls the test function


    you may have a problem setting a forms visibility without it being the focus
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2011
    Location
    Inside your mind
    Posts
    297
    Thanks for the quick reply!

    It's not the form I want to change visibility of, just the submit button.

    I thought I could do something like that, but as I have 6 inputs, and only code for 2 of them (which populate the other combo boxes), I was hoping I could just monitor for any change, globally for the form, to cut down on the amount of code.

    But if I have to setup OnChange events for all of them I guess that's what I'll have to do.

    I'll set each up to a public variable, and write a function that sets the submit button to visible only when all 6 booleans are true, otherwise hide it. Setting the function to call just after its public variable has been set.

    Is that how you'd go about it?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    put your validation into one function, that is called from each controls on change / lost focus

    there should be no need for public variables, no need for multiple booleans, just a single variable within the validation function


    eg
    public function MyTest() as boolean
    NoErrors = 0
    if (sometest) = false then
    NoErrors = NoErrors+1
    endif
    if (anothertest) = false
    NoErrors = NoErrors+1
    endif
    ...und so weiter

    if NoErrors>0 then
    submitbutton.enabled = false
    else
    submitbutton.enabled = true
    endif

    return submitbutton.enabled 'don't know why you'd want to return a value...
    end function

    then in each controls
    on change, on lost focus etc call MyTest
    also you need to set the state when you add a record or move within a recordset (on current)
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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