Record counters for two sub forms

Charlottew14

Registered User.
Local time
Today, 18:11
Joined
Oct 4, 2012
Messages
32
Hi,

I have a form, with three different sub forms on it. Rather than us the record counter at the bottom of the subforms, i'm creating my own using this code:

Private Sub Form_Current()

Dim rst As DAO.Recordset
Dim lngCount As Long
Set rst = Me!subform.Form.RecordsetClone
With rst
.MoveLast
lngCount = .RecordCount
End With
Me.txtCount = "#" & " " & lngCount

End Sub


which works fine. But if I want to count the records in two subforms, how does that work?! I've tried copying and pasting the code again, but I just get an error :(

Any help would be much appreciated!

Thank you!!
 
Charlottew14, when you say you copied I guess you changed the recordset variable names right? If not you have to..
Code:
Dim rst As DAO.Recordset, rstSecond As DAO.Recordset, rstThird As DAO.Recordset
Are you sure you want to do this? As a word of caution,
Allen Browne said:
Don't MoveLast unless you really need to: this will be slow with a large recordset or a recordset drawn across a network.
Also,
Allen Browne said:
Using any of the Move methods (MoveFirst, MoveLast, MoveNext, or MovePrevious) causes an error if the recordset has no records.
 
I'm clueless when it comes to code and a beginner at Access, so I just kind of go with whatever works so I don't know any alternatives to MoveLast :S
 
No, I did not ask you to find an alternative.. My question is, why do you have an alternative when the default gives you the recordcount anyway?
 
I can't seem to make it work accurately without the MoveLast, and my I don't have enough code experience to really understand much of it!
 
you can get the number of records in a form with just

dcount("*",me.recordsource)
 

Users who are viewing this thread

Back
Top Bottom