Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246

    Unanswered: MAking command buttons visible

    Hi
    I have a pop-up modal form that has one combo box and one command button on it. I want the command button to be invisible until the user selects an item from the combo, so I have used the following code in the "OnCurrent" event on the form.

    Private Sub Form_Current()
    If IsNull(cboName) Then
    CommandButton.Visible = False
    Else
    CommandButton.Visible = True
    End If
    End Sub


    The first bit works fine in that I can not see the command button, but even when a selection is made the button is still invisible. I have even used a hidden text box that gets populated by the OnClick event on the combo box and changed the code to do the IsNull check onthis box, but still to no effect.

    Any ideas as to whythis simple bit of code isn't working

    Regards
    John

  2. #2
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    Firstly, I am a macro person but there are many similarities.

    Your code to me looks like it will make the command buttom invisible when you open the form if the combo is empty and the command buttom would be visible if you opened the form and the combo was not empty.

    If it was macros then there would be a SetValue macro running on OnCurrent to make the button invisible and a SetValue on the AfterUpdate on the combo to make the button visible.

    Mike

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    how many times can the current form become current?

    design-view the button as visible:no
    then

    private sub cboName_afterupdate()
    If IsNull(cboName) Then
    CommandButton.Visible = False
    Else
    CommandButton.Visible = True
    End If
    end sub

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    Thanks for the replies Guy's. Izzy I used your example and all is working perfectly

    I'm not sure though that I understand you question re "how many times can the form become current"?

    Regards
    John

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    something that is current cannot become current - it is already current.
    ...the current() event wasn't triggering for you after the initial load.

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Feb 2004
    Location
    UK
    Posts
    246
    I see now izzy, thanks for explaining that

    Cheers
    John

Posting Permissions

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