[RESOLVED] Tab Control Form Set Focus--Now won't hide any pages (tabs)
I was getting an error when trying to hide a page on a tabbed form in access that you can't hide a control that has the focus. So I used a line of code Me.tabIwasnotusing.SetFocus and now it doesn't give me an error but it also isn't hiding any of the tabs as indicated below that line :( Here is the code for the form. I was having trouble with hiding "pgEvaluations"
[/CODE]
Option Compare Database
Option Explicit
Public frmType As String
Private Sub Form_Current()
frmType = Nz(Me.docChangeCategory, "General")
setProperties
End Sub
Private Sub Form_Load()
frmType = Nz(Me.OpenArgs, "")
If frmType = "" Then frmType = "General"
Call setProperties
End Sub
Public Sub setProperties()
showAllPages
Select Case frmType
Case "General"
With Me
.lblCaption.Caption = "Document Information"
End With
Case "Create"
With Me
.lblCaption.Caption = "Create SOP"
hidePage ("pgAnnualReview")
hidePage ("pgRetire")
End With
Case "PenAndInk"
With Me
.lblCaption.Caption = "Pen And Ink SOP"
Me.pgFinalized.SetFocus
hidePage ("pgEquipment")
hidePage ("pgEvaluations")
hidePage ("pgAnnualReview")
hidePage ("pgRetire")
End With
Case "Revise"
With Me
.lblCaption.Caption = "Revise SOP"
hidePage ("pgEquipment")
hidePage ("pgAnnualReview")
hidePage ("pgRetire")
End With
Case "Supplement"
With Me
.lblCaption.Caption = "Supplement SOP"
hidePage ("pgEquipment")
hidePage ("pgAnnualReview")
hidePage ("pgRetire")
End With
Case "Review"
Me.pgAnnualReview.SetFocus
With Me
.lblCaption.Caption = "Annual SOP Review"
hidePage ("pgEquipment")
hidePage ("pgEvaluations")
hidePage ("pgSignatures")
hidePage ("pgFinalized")
hidePage ("pgRetire")
End With
Case "Retire"
Me.pgRetire.SetFocus
With Me
.lblCaption.Caption = "RETIRE (Archive) SOP"
hidePage ("pgEquipment")
hidePage ("pgEvaluations")
hidePage ("pgSignatures")
hidePage ("pgFinalized")
hidePage ("pgAnnualReview")
End With
Case Else
MsgBox frmType
End Select
End Sub
Public Sub showAllPages()
Dim pg As Access.Page
For Each pg In Me.tabControl.Pages
pg.Visible = True
Next pg
End Sub
Public Sub hidePage(pgName As String)
Me.tabControl.Pages(pgName).Visible = False
End Sub
[CODE]
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
Not the right way to do it but not the wrong way either...
Check this for me... Does it work?
Code:
Public Sub hidePage(pgName As String)
Dim pg As Access.Page
For Each pg In Me.tabControl.Pages
If pg.Name = Trim(pgName) Then
pg.Visible = False
Exit Sub
End If
Next pg
End Sub
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
That did not work either. The code I created is hiding the cases Perfectly that do not involve Hide Page pgEvaluations. I was getting an error when I tried to hide it that you can not hide a page that contains the control that has the focus. Then when I set the focus from pgEvaluations to another page for a case that needs to hide pgEvaluations (pen and ink) it shows all of the pages and does not hide any of the tabs.
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
This is my latest version 17. I uploaded it on 4shared.com at the following link:
http://www.4shared.com/file/C1BShL5n...P_DCS_V17.html
Thank you!
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
Whoa! There are so many tables and forms... Which is the form you are referring to? :)
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
the form with the tabs is frmMasterTabForm. Some of the code is also in the class module mdlDocUtilities. This little project has turned into a MONSTER!! But it should be pretty cool when it is done! If it ever works :)
Re: Tab Control Form Set Focus--Now won't hide any pages (tabs)
Change
to
and try again in Public Sub setProperties() ;)
Re: [RESOLVED] Tab Control Form Set Focus--Now won't hide any pages (tabs)
The devil is in the details!!! Sorry I took so long to Thank you, I have jumped into another set of tweaks I need to make. If you want you can check out my most recent post! I changed the pages Evaluations and Signatures on the tab control of frmMasterTabForm and can't get them to filter!
"Filter continuous subform from combo box selection MS Access 2007, Office 2007" new link: http://www.4shared.com/file/p7YqKyff...P_DCS_V26.html
(If you get a minute)
Again Thank you so much! I spent a lot of hours scratching my head over two spaces, I didn't know if I was happy or upset!!! :)
:thumb: