By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

How do you tell which page of a tab control is being displayed?

P: n/a
I would like to test to see which page of a tabl control is being
displayed and then after saving the record display the other page. How
can I do that?

More info:

Tabcontrol Name = TabCtl53
Page Name = tabGeneralInfo
Page Name = tabJudgeInfo

tabGeneralInfo is the 1st page and tabJudgeInfo is the 2nd page. When
the 'save' button is clicked, I want to save the record and if the
current page is tabGeneral I want to display tabJudgeInfo (if the person
is a judge ... based on a test of an unbound option button located on
tabGeneral).

Thanks.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Susan Bricker wrote:
I would like to test to see which page of a tabl control is being
displayed and then after saving the record display the other page. How
can I do that?

More info:

Tabcontrol Name = TabCtl53
Page Name = tabGeneralInfo
Page Name = tabJudgeInfo

tabGeneralInfo is the 1st page and tabJudgeInfo is the 2nd page. When
the 'save' button is clicked, I want to save the record and if the
current page is tabGeneral I want to display tabJudgeInfo (if the person
is a judge ... based on a test of an unbound option button located on
tabGeneral).

Thanks.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***


MsgBox Me.TabCtl53.Pages.Item(Me.TabCtl53).Name

If Me.TabCtl53.Pages.Item(Me.TabCtl53).Name = "tabGeneral" then
Nov 13 '05 #2

P: n/a
Hey, Salad ...

Thanks for the info. Here's what I ended up doing ...

Dim intGeneralInfo As Integer
Dim intJudgeInfo As Integer
If strMode = "ADD" Then
'if (current page is tabGeneralInfo and optJudge = optNOJudge) or
' (current page is tabJudgeInfo) then
' goto new record
intGeneralInfo =
Forms(Me.Name).Controls("TabCtl53").Pages("tabGene ralInfo").PageIndex
intJudgeInfo =
Forms(Me.Name).Controls("TabCtl53").Pages("tabJudg eInfo").PageIndex

If ((Forms(Me.Name).Controls("TabCtl53").Value = intGeneralInfo) _
And (Me!optJudge = NOJUDGE)) _
Or (Forms(Me.Name).Controls("TabCtl53").Value = intJudgeInfo)
Then

DoCmd.GoToRecord , , acNewRec

End If
End If

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
Susan Bricker wrote:
Hey, Salad ...

Thanks for the info. Here's what I ended up doing ...

Dim intGeneralInfo As Integer
Dim intJudgeInfo As Integer
If strMode = "ADD" Then
'if (current page is tabGeneralInfo and optJudge = optNOJudge) or
' (current page is tabJudgeInfo) then
' goto new record
intGeneralInfo =
Forms(Me.Name).Controls("TabCtl53").Pages("tabGene ralInfo").PageIndex
intJudgeInfo =
Forms(Me.Name).Controls("TabCtl53").Pages("tabJudg eInfo").PageIndex

If ((Forms(Me.Name).Controls("TabCtl53").Value = intGeneralInfo) _
And (Me!optJudge = NOJUDGE)) _
Or (Forms(Me.Name).Controls("TabCtl53").Value = intJudgeInfo)
Then

DoCmd.GoToRecord , , acNewRec

End If
End If

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***


Glad it worked. There are other ways to refer to this
Dim tbc As Control
Dim pge As Page

' Return reference to tab control.
Set tbc = Me.TabCtl53
With tbc
MsgBox tbc.Pages(tbc.Value).Name
End With

'not modifying using a Page
Set pge = tbc.Pages(tbc.Value)
MsgBox pge.Name

These might be better than the huge lines....for readability.
Nov 13 '05 #4

P: n/a
Susan Bricker <sl*****@verizon.net> wrote in
news:R1***************@news.uswest.net:
Hey, Salad ...

Thanks for the info. Here's what I ended up doing ...

Dim intGeneralInfo As Integer
Dim intJudgeInfo As Integer
If strMode = "ADD" Then
'if (current page is tabGeneralInfo and optJudge = optNOJudge)
or ' (current page is tabJudgeInfo) then
' goto new record
intGeneralInfo =
Forms(Me.Name).Controls("TabCtl53").Pages ("tabGeneralInfo").PageInd ex
intJudgeInfo =
Forms(Me.Name).Controls("TabCtl53").Pages ("tabJudgeInfo").PageIndex
If ((Forms(Me.Name).Controls("TabCtl53").Value =
intGeneralInfo) _
And (Me!optJudge = NOJUDGE)) _
Or (Forms(Me.Name).Controls("TabCtl53").Value =
intJudgeInfo)
Then

DoCmd.GoToRecord , , acNewRec

End If
End If


This is the perfect case where using a WITH/END WITH block would
make the code far more comprehensible:

Dim intGeneralInfo As Integer
Dim intJudgeInfo As Integer

If strMode = "ADD" Then
With Me!TabCtl53
intGeneralInfo = .Pages("tabGeneralInfo").PageIndex
intJudgeInfo = .Pages("tabJudgeInfo").PageIndex
If .Value = intGeneralInfo And (Me!optJudge = NOJUDGE)) _
Or (.Value = intJudgeInfo)
Then
DoCmd.GoToRecord , , acNewRec
End If
End With
End If

Also, I'm not sure why you needed to use
Forms(Me.Name).Controls("TabCtrl53") instead of just Me!TabCtl53.
The Controls collection is the default collection of the Me object
(actually, it's a combination of the Fields and Controls
collections), so you don't need to specify the collection. It also
is very unnecessary to pass Me.Name to the the Forms collection to
get a reference to the current form, since the current form is Me to
begin with.

And, in a context with multiple instances of the form you're working
with, your method might produce an incorrect reference, as all the
instances of a single form have the same name, but the Me reference
is individual to each instance.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.