Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordCount not working 2

Status
Not open for further replies.

pmp1

Programmer
Jun 17, 2007
29
AU
Hi!
I have reviewed the many other threads on RecordCount and have no reason to think my code should not work, however, it returns the incorrect answer.
Code:
Private Sub Form_Load()
  MsgBox(Str(Me.[ctrlPatientBrowser].Form.Recordset.RecordCount))
End Sub
ctrlPatientBrowser is a subform - datasheet
The answer I get is 501
Clicking on the vertical scroll bar shows "Record: 1 of 1134"
which is correct.
I am obviously missing something basic and would appreciate some help.
Thanking you
Peter
 
Seems that when the Form loads the subform hasn't read all the records yet.
You may try this:
Code:
Private Sub Form_Load()
With Me.[ctrlPatientBrowser].Form.Recordset
  .MoveLast
  MsgBox(Str(.RecordCount))
  .MoveFirst
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you to both PHV and pjm.
I will now also check microsoft for my answers first.
Regards
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top