use a variable with a me.field name

mdlp used Ask the Experts™
I have a form with a set of 20 Command Buttons and 20 unbound Text box's.
tbP1, tbP2, tbP3 - 20
cbP1, cbP2, cbP3 - 20
dim counter as integer
dim sCurrValue

while counter <21
  if isnull(me.tbP(counter)) then
     me.cbP(counter).Visible = False
  sCurrValue = me.tbP(counter)
 end if

How do I correctly make me.tbP"Counter" the same as me.tbP1 -20 for each loop.
I know that I can create 20 if then's, but this list grows and shrinks at different site.

I need to replace the Number in the with the current counter value, I hope I am clear with this question.

Thank you Experts
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Dim i As Integer

Dim sCurrValue As String

Do while i<21

  if isnull(me("tbP" & i)) then
     me("cbP" & i).Visible = False
  sCurrValue = me("tbP" & i)

 end if




Exactly what I needed, thank you

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial