Tab Page coding

G

Guest

I have a form. And on that form there is a tab control with several tab
pages. Each tab page contains specific data and not all pages have data on
them. The users are requesting that when data is present within the "tab
page" the tab itself is colored or highlighted in some way. That way they do
not need to check the other pages because they will know by looking no data
exists under that tab. Is there possibly a way to do this?
 
M

Marshall Barton

Melissa said:
I have a form. And on that form there is a tab control with several tab
pages. Each tab page contains specific data and not all pages have data on
them. The users are requesting that when data is present within the "tab
page" the tab itself is colored or highlighted in some way. That way they do
not need to check the other pages because they will know by looking no data
exists under that tab. Is there possibly a way to do this?


About all you can do with normal access features is make the
tab invisible.

For more elaborate things, look around at www.lebans.com
 
J

John Nurick

Hi Melissa,

As Marsh says, the standard tab control doesn't allow for this. When I
need to signal that there's something on a tab, I put a row of (usually
pale yellow) rectangles on the form just below the actual tabs, one per
tab. Place the rectangles on the form itself, not on the tab pages: that
way their visibility won't be affected by which page is selected.

Then use VBA code that changes the Visible property of each rectangle
according to whether there's anything in the tab. If the form is bound
to a table or query then the code probably needs to go in the form's
Current event procedure.
 
G

Guest

Any suggestions on what code to write for this?

John Nurick said:
Hi Melissa,

As Marsh says, the standard tab control doesn't allow for this. When I
need to signal that there's something on a tab, I put a row of (usually
pale yellow) rectangles on the form just below the actual tabs, one per
tab. Place the rectangles on the form itself, not on the tab pages: that
way their visibility won't be affected by which page is selected.

Then use VBA code that changes the Visible property of each rectangle
according to whether there's anything in the tab. If the form is bound
to a table or query then the code probably needs to go in the form's
Current event procedure.
 
J

John Nurick

It depends on what's on the tabs.

I'll assume that the little rectangles are called shIndicator0,
shIndicator0... on pages 0,1...

If there's a bound subform on each page it should be possible to do
something like this (in the Form's Current event procedure). sfABC,
sfDEF etc. are the names of the subform controls on the respective
pages.

With Me
.shIndicator0.Visible = _
(.sfABC.Form.RecordsetClone.RecordCount <> 0)
.shIndicator1.Visible = _
(.sfDEF.Form.RecordsetClone.RecordCount <> 0)
...
End With

If the controls on the pages are displaying fields from the table or
query the form is bound to, your code will need to examine each control
on each tab page that may contain data but skip those (such as labels
and lines). One useful trick is to use the Tag property of the controls.
If you set this to "CheckMyValue" for each control that may contain
data, your code could do something alone these lines, although it will
almost certainly need refining:

Dim j as Long
Dim C as Control
Dim FlagIt as Boolean
...

With Me.TabControl
For j = 0 To .Pages.Count - 1 'iterate through each page
FlagIt = False
For Each C in .Pages(j).Controls 'and each control on the page
If C.Tag = "CheckMyValue" Then
If Not IsNull(C.Value) Then
FlagIt = True
End If
End If
Next C
Me.Controls("shIndicator" & j).Visible = FlagIt
Next j
End With
 

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