AlanS
05-31-2001, 01:36 PM
I have a main form showing customer records, and a subform showing visit records. When I navigate between records on the main form, the subform correctly shows only those visit records linked to the currently displayed customer. On each form, I need to access both the current record number (CurRec) and the total number of records (TotRec) from VBA code. On the main form, I can do this easily with the following code:
Private Sub Form_Activate()
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acFirst
End Sub
Private Sub Form_Current()
Dim CurRec As Integer, TotRec As Integer
...
CurRec = Me.CurrentRecord
TotRec = Me.RecordsetClone.RecordCount
...
End Sub
However, the same approach does not work on the subform, apparently at least in part because its Activate event never seems to fire, and its Open and Load events fire before the corresponding events on the main form. Since the two forms are linked, the total number of records in the subform must be recalculated each time the main form record changes.
Any suggestions?
Private Sub Form_Activate()
DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acFirst
End Sub
Private Sub Form_Current()
Dim CurRec As Integer, TotRec As Integer
...
CurRec = Me.CurrentRecord
TotRec = Me.RecordsetClone.RecordCount
...
End Sub
However, the same approach does not work on the subform, apparently at least in part because its Activate event never seems to fire, and its Open and Load events fire before the corresponding events on the main form. Since the two forms are linked, the total number of records in the subform must be recalculated each time the main form record changes.
Any suggestions?