SetFocus to a Page Number on a Tabbed Form... Version: 2007 (12.0

T

Terra

I hope someone can help me, you see I have a form and on this form is a
button, when clicked it goes to another form that has a tabbed sub form and
is filtered to the initial form(that I click the button on) ContactID number.
This works great, however
I need it to also set the focus to the tab labeled "SalesInfo" which is page
6,


Here is my code...
Private Sub Command134_Click()
On Error GoTo Err_Command134_Click
Dim strFrmContacts As String

strFrmContacts = "frmContacts"
DoCmd.OpenForm strFrmContacts
With Forms(strFrmContacts)
..Filter = ""
..Filter = "ContactID = " & txtSrBOID
..FilterOn = True
End With

Exit_Command134_Click:
Exit Sub
Err_Command134_Click:
MsgBox Err.Description
Resume Exit_Command134_Click
End Sub

How to I add the SetFocus command and where do I put it...

Kindess regards.....TLH
 
P

Paul Shapiro

Within your code that's filtering frmContacts, add the code to set the tab
control's value to the page index value.

With frmContacts
...
Me.tabControl.value = 6
End With

For more readable code, you can use the page's name:
Me.tabControl.value = Me.pageSalesInfo.pageIndex
 
T

Terra

Paul, thanks for responding. I tried your suggestion, however I am still at a
loss, I don’t know exactly where to put this code. Below is how I put it and
it is not working. It states Method or data member not found or when I just
use the Me.tabControl.value = 6, I get Application-defined or object-defined
error.

Private Sub Command134_Click()
On Error GoTo Err_Command134_Click
Dim strFrmContacts As String
strFrmContacts = "frmContacts"
DoCmd.OpenForm strFrmContacts
With Forms(strFrmContacts)
.Filter = ""
.Filter = "ContactID = " & txtSrBOID
.FilterOn = True
Me.TabControl.Value = Me.SalesInfo.PageIndex


End With



Exit_Command134_Click:
Exit Sub
Err_Command134_Click:
MsgBox Err.Description
Resume Exit_Command134_Click
End Sub

Where do I put your code?

Thanks!
Terra
 
P

Paul Shapiro

Sorry, remove the 'Me' before the names of your subform controls. Me refers
to the present form. You want the reference to be frmContacts, so it should
be something like this:

With Forms(strFrmContacts)
.Filter = ""
.Filter = "ContactID = " & txtSrBOID
.FilterOn = True
.TabControl.Value = .SalesInfo.PageIndex
End With

You need to replace 'TabControl' with the actual name of your tab control
and SalesInfo with the name of the desired page.
 
T

Terra

OMG! I actually figuered it out. I was focusing on the actual tab name
"SalesInfo" when I should have be focusing on the whole tab form. The whole
tabbed form is named "tabContacts" and has 8 tabs on it, one of which is
named "SalesInfo". Now I understand, and it WORKS GREAT!!! Here's my code:

Private Sub Command174_Click()
On Error GoTo Err_Command174_Click

Dim stDocName As String

strFrmContacts = "frmContacts"
DoCmd.OpenForm strFrmContacts, , , "ContactID = " & txtSrBOID
Forms(strFrmContacts)![tabContacts].Value = 6

Exit_Command174_Click:
Exit Sub
Err_Command174_Click:
MsgBox Err.Description
Resume Exit_Command174_Click
End Sub


Thank you Paul so much for your help!

Have a great weekend!
Terra
 

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