for--next confusion

  • Thread starter Thread starter richaluft
  • Start date Start date
R

richaluft

I'm screwing up some basic programming, and need some help. I have a
control on a report. "[RefPIN]", which is an eight digit number.
Because I must put these eight digits into particular spaces on a
preprinted form, I am trying to loop through the digits, and place the
values into controls named RefPIN1 through RefPIN8. I'm trying to use
the following code ( in the OnFormat Event) to loop through the
values, but I'm missing something important (that escapes me), as it
does not run.


For n = 1 To 8

Me.RefPIN(n) = Mid(Me.RefPIN,
n, 1)

Next n

Any help will be greatly appreciated
TIA, Richard
 
I'm screwing up some basic programming, and need some help. I have a
control on a report. "[RefPIN]", which is an eight digit number.
Because I must put these eight digits into particular spaces on a
preprinted form, I am trying to loop through the digits, and place the
values into controls named RefPIN1 through RefPIN8. I'm trying to use
the following code ( in the OnFormat Event) to loop through the
values, but I'm missing something important (that escapes me), as it
does not run.


For n = 1 To 8

Me.RefPIN(n) = Mid(Me.RefPIN,
n, 1)

Next n

Any help will be greatly appreciated


Try this:

Me.Controls("RefPIN" & n) = Mid(Me.RefPIN, n, 1)
 
Hi Richard

You want:
Me("RefPIN" & n)

In other words, construct a string which is the name of the control and then
use that to index the form's Controls collection (which is the default).
 
Back
Top