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

S

SWu

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
 
A

Albert D. Kallal

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.attcanada.net/~kallal.msn/Articles/Grid.htm
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.

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.lebans.com/formatbycriteria.htm

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.mvps.org/access/resources/downloads.htm


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).
 

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