Preventing On-Screen Scrolling

  • Thread starter Thread starter Art Cabot
  • Start date Start date
A

Art Cabot

I know I've done this before, but I just can't remember how I did it...

I have a continuous form in which I have to run through each record to count
the ones that are checked, but I don't want the form to scroll on-screen as I
loop through it. I think there's a way to lock the form while I'm looping,
then unlock it when I'm done, but I just can't remember how, nor can I find
it in Help or Google.

Can someone jog my memory, please?
 
Are you using VBA code to do the counting? Assuming yes, loop through the
RecordsetClone object of the form.
 
I tried that before posting, but each record in the continuous form has a
checkbox and I need to read the status of that box for each record. When I
use RecordsetClone it reads every record as true for the statement "If
Selected then iCount = iCount + 1".

In the past I've done something that "froze" the form on the screen so it
didn't scroll as I cycled through the Recordset object, but that's what I
can't remember.
--
Art Cabot
Director, Information Technology
Sizemore, Inc.


Ken Snell (MVP) said:
Are you using VBA code to do the counting? Assuming yes, loop through the
RecordsetClone object of the form.
 
Hi Art,

Why not just use a dCount expression? I don't see any reason why you should
need code to step through every record in the form (or even if you did, why
this should require the form itself to refresh for each record). Something
as simple as:
dCount("*","YourFormRecordSource","Selected = True")

And, if Selected is a Yes/No datatype (as it should be, if it's bound to a
checkbox on the form), you can just use:
dCount("*","YourFormRecordSource","Selected")

Replace YourFormRecordSource with the name of the table/query which is the
form's actual recordsource.

You can use that to assign the number of Selected records to a variable to
use in VBA code, or as an expression (preceded by "=") in an unbound textbox
in your form's header/footer to display the number of records with the
Selected checkbox set.

HTH,

Rob


Art Cabot said:
I tried that before posting, but each record in the continuous form has a
checkbox and I need to read the status of that box for each record. When I
use RecordsetClone it reads every record as true for the statement "If
Selected then iCount = iCount + 1".

In the past I've done something that "froze" the form on the screen so it
didn't scroll as I cycled through the Recordset object, but that's what I
can't remember.
 
As so often happens, that was so simple I'm ashamed I didn't think of it. I
just knew that I'd "frozen" the screen once before and was trying to
recapture that method, but this way is so much cleaner.

Thanks.
 
You're welcome.

Rob

Art Cabot said:
As so often happens, that was so simple I'm ashamed I didn't think of it.
I
just knew that I'd "frozen" the screen once before and was trying to
recapture that method, but this way is so much cleaner.

Thanks.
 
Back
Top