Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Tab Control's page if subform's recordcount is zero

Status
Not open for further replies.

qwerty70

Technical User
Dec 13, 2005
73
GB
Dear All,

I have a bound main form named frmInTransmittal, it has a tab control (TabCtl6) with 5 pages (Pages0 to 4).
Each page has their own subforms bound to its respective tables. Each 5 subforms have its own field called "InTrans"
that is linked to the mainform's text box called "InTransNum".

What I would like to happen here is that if I'm on the current record or upon opening the mainform, I want the page to be invisible as long as its subform have zero recordcount. If all of them have records, then naturally
I want all 5 pages to be visible.

Here's the code in my mainform, and it gives me an error when I open it:

Run-time error '2165': You can't hide a control that has the focus.

Code:
Private Sub Form_Current()

	Me.TabCtl6.Pages(0).Visible = (Me.[Calculation Sheet].Form.Recordset.RecordCount > 0)
	Me.TabCtl6.Pages(1).Visible = (Me.[Contractor Drawing Submittal].Form.Recordset.RecordCount > 0)
	Me.TabCtl6.Pages(2).Visible = (Me.[Contract].Form.Recordset.RecordCount > 0)
	Me.TabCtl6.Pages(3).Visible = (Me.[Equipment Data Sheet].Form.Recordset.RecordCount > 0)
	Me.TabCtl6.Pages(4).Visible = (Me.[Engineering Drawing].Form.Recordset.RecordCount > 0)

End Sub

Your help is highly appreciated.

qwerty70
 
How are ya qwerty70 . . .

I believe you already know you [blue]can't hide a oontrol while it has the focus.[/blue] Put the focus somewhere else before execution (that somewhere else can be a [blue]hidden textbox[/blue] just for this purpose!).

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
>>that somewhere else can be a hidden textbox just for this purpose!


Not a hidden(invisible) textbox..
You can't do it.


________________________________________________________
Zameer Abdulla
Help to find Missing people
 
Howdy ZmrAbdulla . . .

I should've been more specific . . . [blue]a textbox box with width & height set to zero[/blue] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
TheAceman1, where should I put this textbox? Thanks.

qwerty70
 
qwerty70 . . .

A good place though would be the the top left or right hand corner of the forms header or footer section . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top