Article ID: 128883
Article Last Modified on 7/5/2002
Option Explicit
Function GetXofY (F As Form)
'*******************************************************************
' FUNCTION: GetXofY()
'
' PURPOSE:
' Gets "X of Y" from the record navigation buttons on a form
' where X represents the position of the record in the recordset
' relative to Y, the total number of records.
'
' INPUT:
' F - The form object whose "X of Y" you want to retrieve.
'
' USES:
' In the header or footer section of a form, you can create a text
' box and set its ControlSource property to the following
' expression:
'
' =GetXofY([Forms]![Form Name])
'
' NOTE:
' If the form is a continuous form, you must recalculate the form
' in the Current event for the expression to update as you move
' from record to record. For example
'
' Sub Form_Current()
' Me.Recalc
' End Sub
'
'*******************************************************************
Dim RS As Recordset
On Error Resume Next
Set RS = F.RecordSetClone
RS.MoveLast
RS.BookMark = F.BookMark
If (Err <> 0) Then
GetXofY = RS.RecordCount + 1 & " of " & RS.RecordCount + 1
Else
GetXofY = RS.AbsolutePosition + 1 & " of " & RS.RecordCount
End If
End Function
ControlSource: =GetXofY([Forms]![Form Name])
Left: 0.9 in
Top: 2.75 in
ControlSource: =GetXofY([Orders Subform].Form)
Left: 0.85 in
Top: 3.5 in
Keywords: kbusage KB128883