Making tabs visible based on toggle buttons

rowardHoark

Registered User.
Local time
Today, 17:15
Joined
Jan 14, 2011
Messages
20
I have a form f_select_tests, where I select tests to be conducted using toggle buttons.

Each test has a corresponding tab in a form called f_manage_tests. All tabs are default hidden.
Depending on the tests selected I want corresponding tabs to become visible.

Currently this code for Water_absorbtion test toggle button is not working.

Code:
Private Sub Water_absorbtion_GotFocus()
 
Forms!f_manage_tests.SetFocus
 
Me.Controls("testManagementTab").Pages("waterAbsorbtionTab").Visible = True
 
End Sub
 
Private Sub Water_absorbtion_Click()
Me.Controls("testManagementTab").Pages("waterAbsorbtionTab").visible = Me.Water_absorbtion
End Sub
 
Private Sub Water_absorbtion_Click()
Me.Controls("testManagementTab").Pages("waterAbsorbtionTab").visible = Me.Water_absorbtion
End Sub

When I execute the code I get:
Run-time error 2465
MS Access can't find the field 'testManagementTab' referred to in your expression.

Since the tabs are in a form (f_test_management) different to that where buttons are located (f_select_tests), shouldn't I focus on f_select_tests first?
 
Use

Private Sub Water_absorbtion_Click()
forms("f_test_management").Controls("testManagementTab").Pages("waterAbsor btionTab").visible = forms("f_select_tests").controls("Water_absorbtion")
End Sub


should work, Me is the form that the code is in.

Thanks
 
By the way, are you going to open the form (i.e. the form with the tab control) after you've made your selections? Or the form stays open whilst you make the selections?
 
I have mine on a tick box - does this help ?

If Me.LiabilityZ = False Then
Me.Liability.Visible = False
Else: Me.Liability.Visible = True



Liabilityz is the tick box and liability is the tab name
 
I have mine on a tick box - does this help ?

If Me.LiabilityZ = False Then
Me.Liability.Visible = False
Else: Me.Liability.Visible = True



Liabilityz is the tick box and liability is the tab name
And yours can be one line too, as shown by nathansav:
Code:
Me.Liability.Visible = Me.LiabilityZ
 
By the way, are you going to open the form (i.e. the form with the tab control) after you've made your selections? Or the form stays open whilst you make the selections?

I open the tab form "f_manage_tests" after having made a selection in "f_select_tests" and closing it.

When both forms are open, the code does work.

Code:
forms("f_test_management").Controls("testManagemen tTab").Pages("waterAbsor btionTab").visible = forms("f_select_tests").controls("Water_absorbtion ")

Although I modified the code a little bit, so it wouldn't be dependant on the open forms and only on the entry in the table

Code:
Forms("f_manage_tests").Controls("testManagementTab").Pages("waterAbsorbtionTab").Visible = DLookup("[waterAbsorbtion]", "t_add_information", "[Report_number] = " & A)
Thank you all for leading me into the correct path.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom