Capturing part of control name in variable

TomH

Registered User.
Local time
Today, 10:21
Joined
Nov 3, 2008
Messages
111
I need some help figuring this one out...

I have 50 text controls on a form... 5 types of controls, 10 iterations (for different purposes but analogous). Let's call each set of five controls A,B,C,D,E. They are iterated with a 2-digit suffix, such that there is A01, A02.... A10, with matching controls of B01 - B10 etc.

Controls A are limited to 2 entries... think of them as True-False. What I want to do is make it so that if A01 is True, B01 and D01 are visible. If A01 is False, then C01 and E01 are visible instead.

I'd like to write update code, and could do so for each of the ten A controls, but I'd rather capture the "01" in a variable and then write code in a function or procedure that's called by each of the update codes in the A controls. The command is identical for each of the ten ABCDE set of controls in the A afterupdates except for the two digit suffix.


I hope this is clear... and any help is grrrrrrrrrrreatly appreciated.
 
You can refer to a control on a form or report by using the variable part like this:

If Forms!FormNameHere.Controls("A" & Format(intCount), "00").Value
 
Last edited:
Thanks, Bob. I think I might be a little behind here yet.

I've set all the B,C,D,E controls visible = false.

Here's what I'm trying to simplify:

A01 Afterupdate
If Me.A01.Value = True Then
Me.B01.Visible = True
Me.D01.Visible = True
End If
If Me.A01.Value = False Then
Me.C01.Visible = True
Me.E01.Visible = True
End If
End Sub

This same code would be used for all ten of the A01 - A10 . I'm trying to find a way of building the logic into a procedure where all I would have in the afterupdate is a call based on the If, and all 10 afterupdates code would be identical. I don't know... maybe I'm overcomplicating this?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom