Re: variables and for next statements

Tech-Archive recommends: Fix windows errors by optimizing your registry



Biggles wrote:

I currently have this code

ME.WD_FULL_HRS.VISIBLE = TRUE

ME.TX_FULL_HRS.VISIBLE = TRUE

ME.ITAG_FULL_HRS.VISIBLE = TRUE

there are many more fields of the same naming convention.

Ok, what I would like to do is:

For Each GRP in ("WD","TX","ITAG")
FHRS = "ME." & GRP & "_FULL_HRS"
EXIT FOR
NEXT

FHRS.VISIBLE = TRUE


Dim Itm As Variant
Dim Grp As Variant
For Each Itm IN Array("_FULL_HRS", . . .)
For Each Grp In Array("WD", "TX", "ITAG")
Me(Grp & Itm).Visible = True
Next Grp
Next Itm

--
Marsh
MVP [MS Access]
.



Relevant Pages

  • Re: how can test the existence of an item within a collection vba
    ... Here's a rather generic algorithm taken ... val As Variant) As ... Dim itm As Variant ... On Error GoTo 0 ...
    (microsoft.public.office.developer.vba)
  • Re: Clear
    ... you can create an array on-the-fly from individual or indexed controls: ... Dim itm As Variant ... For Each itm In Array(Text1, Text3, Text5) ...
    (microsoft.public.vb.general.discussion)