Count sfrm records

A

alex

Count sfrm records

Hello,

I have the following as a control source of unbound txtbox on a main
form:
=[Forms]![frmMain]![frmSfrm].[Form].[RecordsetClone].[RecordCount]

Interestingly, this works with a record count of <= 501; i.e., when
the record count is > 501, the count will stop at 501.

When I click the sfrm, the textbox will update with the correct count;
e.g., 750.

I tried requery or recalc, but nothing works until I click the sfrm.

Any thoughts?
alex
 
T

Tom van Stiphout

On Thu, 21 Jan 2010 08:28:15 -0800 (PST), alex <[email protected]>
wrote:

That's normal, because Access lazily loads the records. It's done this
way for performance reasons.
Off the top of my head, you can set the controlsource of your textbox
to:
=GetSubformRecordCount()
Then create a public function in your parent form:
public function GetSubformRecordCount() as long
with me.frmSfrm.form.recordsetclone
if .recordcount > 0 then
.movelast
GetSubformRecordCount = .RecordCount
else
GetSubformRecordCount = 0
end if
end with
end function

-Tom.
Microsoft Access MVP
 
A

alex

That's normal, because Access lazily loads the records. It's done this
way for performance reasons.
Off the top of my head, you can set the controlsource of your textbox
to:
=GetSubformRecordCount()
Then create a public function in your parent form:
public function GetSubformRecordCount() as long
with me.frmSfrm.form.recordsetclone
  if .recordcount > 0 then
    .movelast
    GetSubformRecordCount = .RecordCount
  else
    GetSubformRecordCount = 0
  end if
end with
end function

-Tom.
Microsoft Access MVP


Count sfrm records

I have the following as a control source of unbound txtbox on a main
form:
=[Forms]![frmMain]![frmSfrm].[Form].[RecordsetClone].[RecordCount]
Interestingly, this works with a record count of <= 501; i.e., when
the record count is > 501, the count will stop at 501.
When I click the sfrm, the textbox will update with the correct count;
e.g., 750.
I tried requery or recalc, but nothing works until I click the sfrm.
Any thoughts?
alex- Hide quoted text -

- Show quoted text -

Top of your head's pretty smart Tom...that worked just fine (I had to
requery the txtbox in a few places).
Thanks,
alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top