FOR..NEXT

  • Thread starter Thread starter SPB
  • Start date Start date
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
 
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
 
Back
Top