How to get active tab properties?

A

Adrian

Access 2000

I am developing a Help System for our database and have the following code
in a module to get the HelpcontextID. Here is the part that gets the ID:

-------------
Dim curForm As Form
Dim FormHelpId As Long

'Set the curForm variable to the currently active form.
Set curForm = Screen.ActiveForm

FormHelpId = 1001

If curForm.ActiveControl.Properties("HelpcontextId") > 0 Then 'There is a
HelpcontextId for the control so get this
FormHelpId = curForm.ActiveControl.Properties("HelpcontextId")
Else
If curForm.HelpContextId > 0 Then 'There is a HelpcontextId for the
form
FormHelpId = curForm.HelpContextId
End If
End If
-------------

How can I get the HelpcontextIF for the active tabbed page on the active
form? The above code gets the HelpcontextID for the active control if there
is an ID, and if not gets the form ID.

Thanks for any help.

Adrain.
 
B

Billy Yao [MSFT]

Hi Adrian,

Thank you for posting in the community. It's my pleasure to assist you with this issue.

From your description, I understand that your provided code have successfully got the
HelpcontextID property for the active control and now you want to navigate to you would like
to get this property for the active tabbed page on your form. Have I understood the issue
correctly and completely? If there is anything I misunderstood, please feel free to let me
know.

Based on my experience, you can assign the Help Context ID to your Table control in the
'Other' pan of the Table control Properties. In the result, the HelpContextID properties in all
the tabbed pages are the same as your Table control's. The following code proves this:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub TabCtl0_Change()
MsgBox Me.TabCtl0.Value
If Me.TabCtl0.Value = 0 Then
Me.TabCtl0.HelpContextId = "1001"
Else
Me.TabCtl0.HelpContextId = "1002"
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

To get the HelpcontextID property of the tabbed page on the active form, the following code
may help get this property from the current control if it is assigned with an ID:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Page1_Click()
Dim curForm As Form
Dim ctlCurrentControl As Control
Dim FormHelpId As Long


Set curForm = Screen.ActiveForm
Set ctlCurrentControl = Screen.ActiveControl

FormHelpId = 1001

If ctlCurrentControl.Pages(0).Properties("HelpcontextId") > 0 Then
FormHelpId = ctlCurrentControl.Pages(0).Properties("HelpcontextId")
Else
If curForm.HelpContextId > 0 Then
FormHelpId = curForm.HelpContextId
End If
End If

'Debug.Print FormHelpId

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Adrian, does this answer your question? Please feel free to post in the group if this solves
your problem or if you would like further assistance. Thank you for choosing Microsoft!

Best regards,

Billy Yao
Microsoft Online Support
 
B

Billy Yao [MSFT]

Hello Adrian,

Thank you for posting in the community. It's my pleasure to assist you with this issue.

From your description, I understand that your provided code have successfully got the
HelpcontextID property for the active control and now you want to navigate to you would like
to get this property for the active tabbed page on your form. Have I understood the issue
correctly and completely? If there is anything I misunderstood, please feel free to let me
know.

Based on my experience, you can assign the Help Context ID to your Tab Control in the
'Other' pan of the Tab Control Properties. In the result, the HelpContextID properties in all the
tabbed pages have the same value. The following code proves this:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub TabCtl0_Change()
MsgBox Me.TabCtl0.Value
If Me.TabCtl0.Value = 0 Then
Me.TabCtl0.HelpContextId = "1001"
Else
Me.TabCtl0.HelpContextId = "1002"
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

To get the HelpcontextID property of the tabbed page on the active form, the following code
may help get this property from the current control if it is assigned with an ID:

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Page1_Click()
Dim curForm As Form
Dim ctlCurrentControl As Control
Dim FormHelpId As Long


Set curForm = Screen.ActiveForm
Set ctlCurrentControl = Screen.ActiveControl

FormHelpId = 1001

If ctlCurrentControl.Pages(0).Properties("HelpcontextId") > 0 Then
FormHelpId = ctlCurrentControl.Pages(0).Properties("HelpcontextId")
Else
If curForm.HelpContextId > 0 Then
FormHelpId = curForm.HelpContextId
End If
End If

'Debug.Print FormHelpId

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Adrian, does this answer your question? Please feel free to post in the group if this solves
your problem or if you would like further assistance. Thank you for choosing Microsoft!

Best regards,

Billy Yao
Microsoft Online Support
 
A

Adrian

Billy,

Thanks for you help.

I tried this and get the following error:

'Run-Time error 2455' 'You entered an expression that has an invalid
reference to the properties pages'

Any suggestions.

Thanks,

Andy
"Billy Yao [MSFT]" said:
Hello Adrian,

Thank you for posting in the community. It's my pleasure to assist you with this issue.

From your description, I understand that your provided code have successfully got the
HelpcontextID property for the active control and now you want to navigate to you would like
to get this property for the active tabbed page on your form. Have I understood the issue
correctly and completely? If there is anything I misunderstood, please feel free to let me
know.

Based on my experience, you can assign the Help Context ID to your Tab Control in the
'Other' pan of the Tab Control Properties. In the result, the
HelpContextID properties in all the
 
B

Billy Yao [MSFT]

Hi Andy,

Thank you for your feedback and let me know your status.

I re-tested the code on my side. It works fine on a simple testing form containing only one
Tab Control with the two pages (Page 1 and Page 2). I'm not 100% sure why it cannot be
applied on your side, but please try the

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If ctlCurrentControl.Properties("HelpcontextId") > 0 Then
FormHelpId = ctlCurrentControl.Properties("HelpcontextId")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

directly instead of referencing the property of pages(0) as below

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ctlCurrentControl.Pages(0).Properties("HelpcontextId")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

On the other hand, if you use the Access 97, when attempting to use the Form property of a
subform control, you will get that runtime error 2445. The error occurs if attempting to
reference the Subform's Form property during:

1. OnCurrent event of the master form
2. For a form in a tab control
3. While using find in another control also in the tab control

In this scenario, you can take the following actions to see if the problem still exists:

In the OnCurrent event, before referencing the Form property, add a line that uses the
SetFocus property to move focus to a control that isn't in the tab control but elsewhere in the
detail section.

If there is anything more I can do to assist you, please feel free to let me know.

Best regards,

Billy Yao
Microsoft Online Support
 
B

Billy Yao [MSFT]

Hi Adrian

How is things going on your side? We wonder if you can get the
HelpcontextIF for the active tabbed page on the active
form. I would appreciate it if you could post here to let me know the
status of the issue. If you have any questions or concerns, please don't
hesitate to let me know.

I look forward to hearing from you, and I am happy to be of assistance.
Thanks!

Best regards,

Billy Yao
Microsoft Online Support
 
A

Adrian

Billy,

I have finally got it to work. I think much of the problem was my lack of
understanding about how tab controls, pages etc work.

I am using the OnChange event of the Tab Control (in this example called
'TabCtl1) to pass the HelpContextId to the form HelpContextId:

Me.HelpContextId = TabCtl1.Pages(TabCtl1.Value).HelpContextId

Adrian
 
B

Billy Yao [MSFT]

Hi Adrian,

Thank you for your feedback! I'm glad the problem has been resolved and
greatly appreciate your ongoing efforts trying my suggestion. It's really
nice to work with you and I hope you're delighted with my support.

If you have any concerns regarding the experience of this issue, please
feel free to let me know. Thank you for posting in the community!

Have a nice day,

Billy Yao
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top