Visible Property and Tab Control

raweber

Registered User.
Local time
Today, 11:35
Joined
Jul 28, 2011
Messages
41
I have a form where certain items are made visible and invisible as needed by check boxes and buttons. I had everything working just fine. Then I moved everything into a Tab Control so I could have multiple tabs on the page. Now nothing turns on and off as I click the controls.

Did moving the elements of the form into the tab control break the Visible Property? Or did my using Cut and Paste to mve them there do it?

Any ideas? If this won't work, I'll just create different forms and use buttons to navigate between them, but I thought using tabs would be slicker.

Thanks, Rob
 
If the controls in question were simply moved from the form's Detail Section directly to a page of the tabbed control, you need to "reconnect" the controls and their event codes.

Courtesy of ADezii at Bytes.com, this code will "reconnect" controls to some selected Events (OnClick and AfterUpdate in this example.) It can be modified for other Events, and has the advantage of updating a large number of controls without doing them one by one.
Code:
Private Sub Form_Load()
Dim ctl As Control

For Each ctl In Me.Controls
If (TypeOf ctl Is CheckBox) Or (TypeOf ctl Is ComboBox) Then
If ctl.OnClick = "" Then
ctl.OnClick = "[Event Procedure]"
End If
End If
Next

For Each ctl In Me.Controls
 If (TypeOf ctl Is TextBox) Or (TypeOf ctl Is ComboBox) Then
   If ctl.AfterUpdate = "" Then
     ctl.AfterUpdate = "[Event Procedure]"
   End If
 End If
Next
End Sub
Alternatively, in Design View, you can select a control, go into Properties Events and click on the event in question, to take you to the code window, as if you were setting it up for the first time. Once in the code window, simply return to Design View. The control is now "connected" to its code and the hotkey will work. The disadvantage to this is that it's time consuming if it involves a lot of controls.

Linq ;0)>
 
Last edited:
That did it. Thanks, Linq!

Rob
 

Users who are viewing this thread

Back
Top Bottom