Substution in an identifier linked to a form

G

Guest

To kepe tis simple:
a form has 3 text boxes; Text1, Text2, Text3

Code that works
Text1 = var

Now trying the following

for i = 1 to 3
Forms!fname!Text & i = var(i)
next i

Having problems with the construct for the identifier. Remember an
undocumented approach but can not locate my notes. Can anyone help?

Thanks
 
G

Guest

Hi George,

Try this. I ran this code in a stand-alone module. The form was open at the
time (of course):

Option Compare Database
Option Explicit
Option Base 1 'Change the default index of the first element from 0 to 1.

Function SetValues(strFormName As String)

Dim frm As Form
Dim var(3) As String
Dim i As Integer

Set frm = Forms(strFormName)

var(1) = "Happy"
var(2) = "New"
var(3) = "Year!"

For i = 1 To 3
frm.Controls("Text" & i) = var(i)
Next i


End Function




Happy New Year,

Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

To kepe tis simple:
a form has 3 text boxes; Text1, Text2, Text3

Code that works
Text1 = var

Now trying the following

for i = 1 to 3
Forms!fname!Text & i = var(i)
next i

Having problems with the construct for the identifier. Remember an
undocumented approach but can not locate my notes. Can anyone help?

Thanks
 

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