Re: How can I format label name as I loop through records?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"David Anderson" <DavidAnderson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:15E4EEB8-E99E-49F6-94DB-F21FAB370F7C@xxxxxxxxxxxxx
> I have a subform with a relatively small (under 40) maximum number of
> records for each main form record. I'm using a tab control to
> identify all the potential subform records, whether present or not
> (this is a cosmetic feature - no data is actually stored on the tab
> control pages). My application is working fine but I would like to
> add an indicator above each tab to show whether or not that
> particular record exists.
>
> I have created small 'marker' labels above each tab and want to make
> these labels visible when the subform record is missing (and vice
> versa). My plan is to loop through the recordsetclone of the subform
> and hide the labels for all the records I find. All other marker
> labels would then be made visible. The labels have been given the
> names TabFlag0, TabFlag1, TabFlag2 ....... TabFlag38.
>
> My problem is that I can't currently think of a way to automatically
> select the correct label as I step through the loop. Obviously I need
> to concatenate "TabFlag" and the current loop counter value but I
> don't know how to create an executable line of code using this
> assembled label name.
>
> I suspect that there is a very simple solution ........

I wonder about your design, since it's usually a bad idea to embed data
content in form design, as you appear to be doing with your tabs and
labels. However, the simple answer to your question is to concatenate
the "TabFlag" prefix with your loop counter and use the result as a
string index into the Control collection, like this:

Dim I As Integer

For I = 0 to 38
Me.Controls("TabFlag" & I).Visible = False
Next I

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.



Relevant Pages

  • Re: Subform trouble for New User
    ... control as suggested. ... I didn't use that field in the Subform Field Linker). ... The structure of this tab is ... continuous form.I have limited the fields in the continuous form to ...
    (microsoft.public.access.forms)
  • Re: set focus & screen movement
    ... still pragmatic reality is that the subform is tall/long and since it is the ... sole control in the tab page splitting it is problematic and not what the ... but when one goes into the subform then it always slides up automatically - ...
    (microsoft.public.access.formscoding)
  • Re: Tab control with one subform on five tabs
    ... > subform control and then the filtering will be automatic. ... but if not then you couold dispense with the tab control entirely ... > and use an option group with one button for each day ...
    (microsoft.public.access.formscoding)
  • Re: Tab control and subforms
    ... Then the PageIndex of the page being selected must be something other than 1 ... ....Tab3 is the name of the first tab on the subform ... Well, if Me is the main form, and the main form doesn't have a control named ...
    (microsoft.public.access.formscoding)
  • Re: Form Design - Data Entry
    ... > Place the controls from Table1 onto the first page of the tab control. ... > There are many ways to make a subform, including using the subform wizard in ... > Would it be preferable to break the form down into separate interface parts ...
    (microsoft.public.access.forms)