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

Indication for hidden tab records

P: n/a
I have a form with 2 tabs. When tab1 is in front I somehow would like to
show the user that there are records (or not) in the subform in tab2. What
is the best way to achieve this? Is there some common method to do this?

Thank you.
John
Nov 18 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
John J. wrote:
I have a form with 2 tabs. When tab1 is in front I somehow would like to
show the user that there are records (or not) in the subform in tab2. What
is the best way to achieve this? Is there some common method to do this?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You'll have to check each dataset in each sub-form. I use the following
function to get the sub-forms' dataset indication.

Call the function like this:

If SubFormHasData(Me!SubForm_Name.Form) Then
<true stuff>
Else
<false stuff>
End If

Public Function SubFormHasData(frm As Form) As Boolean
' Purpose:
' Determine if the indicated subform has any data.
' In:
' frm A reference to the indicated form.
' Out:
' True The subform has data
' False It doesn't...
' Created:
' mgf 1aug2006
' Modified:
'

On Error Resume Next ' Errors are ignored

Dim rs As DAO.Recordset

Set rs = frm.RecordsetClone

rs.MoveLast

SubFormHasData = (rs.RecordCount 0)

On Error Resume Next
Set rs = Nothing

End Function

About the only thing that will change the display on the Tab control's
Pages would be the Caption property of each Page. E.g.:

If SubFormHasData(Me!frmGMT_Time.Form) Then

' frmGMT_Time is on Page(0)

Me!TabName.Pages(0).Caption = Me!TabName.Pages(0).Caption & "+"

Else

Me!TabName.Pages(0).Caption = _
Replace(Me!TabName.Pages(0).Caption, "+", "") & "-"

End If

Tab pages index starts at Zero.

In the above example I just added a "+" to the Page Caption when there
was data in the subform and added a "-" when there wasn't any data.

You'll have to call the final routine, that you come up with, from the
Form's OnCurrent event procedure, so that, each time a different record
is selected, the Tab Pages' Captions will be updated.

--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSSM7W4echKqOuFEgEQLFZwCgqYC1JNyUpSYCGQmwX5VJNN TbtvYAn2t1
5TJBWWzIFIvDjvWHETTqLkfQ
=j84L
-----END PGP SIGNATURE-----
Nov 18 '08 #2

P: n/a
Thanks. I accidentally crossposted this question as I initially posted it to
the 'wrong' ng.
I already solved it with Arvin Meijer's code, but this generic idea will
come in handy when dealing with multiple tabs.

John

"MGFoster" <me@privacy.comschreef in bericht
news:DZ******************************@earthlink.co m...
John J. wrote:
>I have a form with 2 tabs. When tab1 is in front I somehow would like to
show the user that there are records (or not) in the subform in tab2.
What is the best way to achieve this? Is there some common method to do
this?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You'll have to check each dataset in each sub-form. I use the following
function to get the sub-forms' dataset indication.

Call the function like this:

If SubFormHasData(Me!SubForm_Name.Form) Then
<true stuff>
Else
<false stuff>
End If

Public Function SubFormHasData(frm As Form) As Boolean
' Purpose:
' Determine if the indicated subform has any data.
' In:
' frm A reference to the indicated form.
' Out:
' True The subform has data
' False It doesn't...
' Created:
' mgf 1aug2006
' Modified:
'

On Error Resume Next ' Errors are ignored

Dim rs As DAO.Recordset

Set rs = frm.RecordsetClone

rs.MoveLast

SubFormHasData = (rs.RecordCount 0)

On Error Resume Next
Set rs = Nothing

End Function

About the only thing that will change the display on the Tab control's
Pages would be the Caption property of each Page. E.g.:

If SubFormHasData(Me!frmGMT_Time.Form) Then

' frmGMT_Time is on Page(0)

Me!TabName.Pages(0).Caption = Me!TabName.Pages(0).Caption & "+"

Else

Me!TabName.Pages(0).Caption = _
Replace(Me!TabName.Pages(0).Caption, "+", "") & "-"

End If

Tab pages index starts at Zero.

In the above example I just added a "+" to the Page Caption when there
was data in the subform and added a "-" when there wasn't any data.

You'll have to call the final routine, that you come up with, from the
Form's OnCurrent event procedure, so that, each time a different record
is selected, the Tab Pages' Captions will be updated.

--
MGFoster:::mgf00 <atearthlink <decimal-pointnet
Oakland, CA (USA)
** Respond only to this newsgroup. I DO NOT respond to emails **

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBSSM7W4echKqOuFEgEQLFZwCgqYC1JNyUpSYCGQmwX5VJNN TbtvYAn2t1
5TJBWWzIFIvDjvWHETTqLkfQ
=j84L
-----END PGP SIGNATURE-----

Nov 19 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.