for--next confusion

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
 
D

Dirk Goldgar

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)
 
G

Graham Mandeno

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top