help!! want to know record count

  • Thread starter Thread starter dan
  • Start date Start date
D

dan

When a form opens I want to display the record count. In
one form I use Me.Form.RecordsetClone.RecordCount and this
works. However, on a different form I use the same thing
but it always returns 1 - and this isn't the case.

I set a visible text box with this value on Form_load,
although I have tried doing it in Current, but this
doesn't work either. The form that works has it done in
Load.

Can anyone tell me how to get this to work??

Thanks,

dan.
 
You probably don't need ".Form", Me refers to the form or report that the statement is in.
What happens if you use

Me.Recordset.Recordcount
 
Recordset isn't a member of a form/me. As expected, it
threw up an error. the funny thing is
Me.Form.RecordsetClone.RecordCount has occasionally worked
and shown the correct number of records. However, most of
the time it doesn't.

why, why, why, why, why????

cheers,

dan.
-----Original Message-----
You probably don't need ".Form", Me refers to the form or
report that the statement is in.
 
Interestingly, I've just noticed that if I close the form
completely, then open it in design more then select
view/form. It still doesn't work. However, from there, I
go view/design and then view/form, then the correct number
appears...?? It seems to me that the value of
Me.Form.RecordsetClone.RecordCount is being set
asynchronously and when I am retrieving its value, I am
missing it. Maybe the oncurrent even fires as soon as the
form has the first record, and then retrieves the rest
asynchronously, allowing the user to get on with it
whatever they're doing.

So, if this is right, how do I know when this value is set
correctly? Appart from starting a very hacky timer for a
few seconds, allowing access to set the value?????

Cheers,

Dan.

-----Original Message-----
You probably don't need ".Form", Me refers to the form or
report that the statement is in.
 
I assume you are using MDB / MDE format. Try in the Form_Load Event


Dim rs As Object

Set rs = Me.RecordsetClone
rs.MoveLast
Me.TextBox1 = rs.RecordCount

Your guess is correct: I am fairly sure the VBA code and the loading of the
Form's Recordset run asynchronously. I had cases that the same Form behaves
differently between fast and slow computers.

--
HTH
Van T. Dinh
MVP (Access)



message news:[email protected]...
 
Add an unbound control to you form and set the control
source =[formName].Form.[Recordset].[RecordCount]

Jim
 
I could try that, however I want to create multiple
instances of the said form. If I specify the source as =
[myFormName].Form.[Recordset].[RecordCount] then won't
that cause problems when there are multiple instances of
that form open??

Cheers,

Dan.
-----Original Message-----
Add an unbound control to you form and set the control
source =[formName].Form.[Recordset].[RecordCount]

Jim
-----Original Message-----
When a form opens I want to display the record count. In
one form I use Me.Form.RecordsetClone.RecordCount and this
works. However, on a different form I use the same thing
but it always returns 1 - and this isn't the case.

I set a visible text box with this value on Form_load,
although I have tried doing it in Current, but this
doesn't work either. The form that works has it done in
Load.

Can anyone tell me how to get this to work??

Thanks,

dan.
.
.
 
Dan,

Van's method should work around the idiosyncrasies you appear to be encountering by making
sure the recordset clone is fully populated. Using Recordset directly (instead of the
clone) requires Access 2000 or newer, you didn't mention your version.
 
Back
Top