ctdak said:
----- Dirk Goldgar wrote: -----
the > following would work as a way of processing all records in
a form, > correct?:
Coupled with
DoCmd.GoToRecord , , acNext
or
RunCommand acCmdRecordsGoToNext
inside the loop, it would.
and > queries, and frankly I can't see the point of what you
said, but then > I'm a relative novice with VBA. Why create a
query or recordset out > of a form that already has the records
and fields you need to > sequentially process?
Why put the application through all the overhead of graphically
representing your movement through the form's recordset by
redisplaying the form and all its controls each time you go to
another record? It will take much longer, showing the user
things he doesn't need to see and mustn't interfere with.
Dirk,
I'm not putting the application through graphical overhead. I didn't
mention it before, but the forms that I'm sequentially processing are
hidden while this is happening. The user doesn't know or see what's
going on and can't interfere with what's happening. Is doing things
this way considered to be generally poor VBA programming practice?
Since I'm new with VBA I don't know, but it's working just fine for
me.
I would have to set of benchmarks to demonstrate it, but I believe that
you *are* putting the application through graphical overhead, even
though the user isn't seeing it because the forms are hidden. It's
clear that a whole lot of things must happen behind the scenes, in the
normal way of things, for a form (a graphical object) to move from one
record to the next. Now, since the form itself must use a recordset of
its own to manipulate the records it is displaying, anything that a form
does besides the basic Recordset.MoveNext must be in addition to the
processing handled by the recordset. It *may* be that almost all of
that is suppressed when the form is not visible, but I wouldn't count on
it, nor is it even possible that all of it is, since there must at the
bare minimum be the extra layer of handling between the DoCmd.GoToRecord
call (made to the application, not the form), and the internal
Recordset.MoveNext call.
There's no question but that looping through the records via
DoCmd.GoToRecord will work. Is it poor programming practice? I don't
set myself up as an arbiter of good or bad practice, so it's not for me
to say. I don't think it's harmful in any way; I just think it's
wasteful. I hope you aren't opening forms in hidden mode just so that
you can loop through their recordsets via DoCmd.GoToRecord! That would
reflect the (IMO) faulty belief that a form is a container of data,
rather than just a window on the data that is contained in the tables.