FOR..NEXT

S

SPB

I have a series of 120 statements examples below, that
change/update a forms caption's from a database, how do I
can change the statement's for use within a FOR..NEXT


Forms![OperationsRTC].OpsDescription1.Caption = Forms!
[frmdetails].OpDescription1
.........
Forms![OperationsRTC].OpsDescription120.Caption = Forms!
[frmdetails].OpDescription120

Thanks
 
D

Dirk Goldgar

SPB said:
I have a series of 120 statements examples below, that
change/update a forms caption's from a database, how do I
can change the statement's for use within a FOR..NEXT


Forms![OperationsRTC].OpsDescription1.Caption = Forms!
[frmdetails].OpDescription1
........
Forms![OperationsRTC].OpsDescription120.Caption = Forms!
[frmdetails].OpDescription120

Thanks

Yikes! It's an odd situation to have to deal with; would you be
interested in explaining what's going on? Regardless, you can ise a
string index into the form's Controls collection, and you can build that
index in a loop. Like this:

Dim intI As Integer
Dim strControlName As String

' Define these for more efficient references
Dim frmOps As Form
Dim frmDtl As Form

Set frmOps = Forms!OperationsRTC
Set frmDtl = Forms!frmDetails

For intI = 1 To 120

strControlName = "OpsDescription" & intI

frmOps.Controls(strControlName).Caption = _
frmDtl.Controls(strControlName).Value

Next intI

Set frmOps = Nothing
Set frmDtl = Nothing
 

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