How do you reference controls record by record on a form that displays many records?

How do you reference controls record by record on a form that displays many records?

Post by SWu » Sun, 13 Jun 2004 14:18:08


Hi everyone

How do you reference controls record by record on a form that displays many
records?

I've created a form with a detail section that displays all records from a
table. In code, when I reference a control and its properties in the
details section (e.g. Address1.ForeColor), it affects ALL Address1
textboxes. If I change the forecolor for Address1, all 10 or 20 or however
many records there are, get affected. How do you refer to Address1 for any
particular record?

Also, is there an event that fires repeatedly when the form shows all
records?

Please don't tell me to use Conditional Formatting as that doesn't apply to
all controls plus doesn't give me enough flexibility for what I want to do.

This should be pretty simple for someone used to coding Access VBA (I'm new
to it but old at VB in general!). Any help at all that gets me looking in
the right direction would be greatly appreciated.

TIA,
Stephen
 
 
 

How do you reference controls record by record on a form that displays many records?

Post by Albert D. » Sun, 13 Jun 2004 14:23:41

>>Re: how do you reference individual controls for selected record on a
form?

Well, you can't since they are not individual controls. A continues form
simply repeats the data, but does NOT repeat (clone) the controls.

This approach is MUCH different then using a data repeater control in VB, or
even using the clone method, and a control array in vb (both of which
requite a lot of code..but make separate instances for each record (and the
associated extra overhead of such an approach).

Of course, the advantage of the access setup is that you can fully design a
detail line as a grid, and it repeats the data for you (I have wished for
this ability in VB for years). There is some nice screen shots of using
continues forms in ms-access here (this shots might give you some ideas).

http://www.yqcomputer.com/ ~kallal.msn/Articles/Grid.htm

to
do.

The above is one of your choices. If conditional formatting can't be used in
your special case, then your choices for using a sub-form are limited.

There is some sample code here to highlight stuff:

http://www.yqcomputer.com/

There is also a few kluge examples that can be used in the following link
(but, I don't like them, and they are for versions of access that did NOT
have conditional formatting (access97 and earlier). However, you might just
take a look at them, those examples can be found here:

http://www.yqcomputer.com/


You can also consider using a 3rd party grid. (perhaps your favorite grid in
VB comes to mind here?)

So, last but not least...I suppose you could use your favorite VB control
(since you mention that this is a snap. Most, if not all VB grid controls do
work in ms-access (in fact, most activeX controls do work). So, if your
super easy snappy and simple to use VB solution exists....then why not use
that solution to solve this problem and be done with it? (you will not be
using a sub-form..but your VB solution should work here).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
XXXX@XXXXX.COM
http://www.yqcomputer.com/ ~kallal.msn