John J. wrote:
Quote:
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-----