subform focus to make control visible

Wysy

Registered User.
Local time
Today, 10:26
Joined
Jul 5, 2015
Messages
335
Hi,
I am struggling with the following and kindly ask for advise.
I have a navigation form with a tabcontrol holding three different subforms. In the main form there is a command button to print a report. OnLoad of the form its visibility is set to false. However when i click on one specific tab holding a specific subform i would like it to be visible. I have tried this without success:

Private Sub Form_Current()
If Forms!frmStart.NavigationSubform.Form.frmPartner.Form.Name =
"fsubPartnerHorse" Then
me.cmdPrint.visible=true
End If
End Sub

Any advise?
thank you
Andy
 
I'm not sure Form current is the correct event.

Try using the TabChange event .
 
Form Current only fires on navigation or update actions. You have done neither.

To supplement Minty's suggestion, here is a link to the documentation.

https://docs.microsoft.com/en-us/office/vba/api/access.tabcontrol.change

On the left side of the page you will see that you could chose a Change event or some click-related events to drive this process. But there is no Load or Current event for a tab. Those events only apply to the form as a whole.
 
if it's hard doing it the way you want, you could try having it visible all the while, but refusing to run the code unless the conditions you want are met. Not ideal, perhaps, but not hard to do.
 
The OnChange did the trick! As tab.value identified the pages this code did what i need: to show the command button in only certain situation:

Private Sub TabCtl0_Click()
If Me.TabCtl0.Value = 1 Then
Me.Command3.Visible = False
Else
Me.Command3.Visible = True
End If
End Sub
Thank you!
 

Users who are viewing this thread

Back
Top Bottom