Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax problem with loop 2

Status
Not open for further replies.

BusMgr

IS-IT--Management
Joined
Aug 21, 2001
Messages
138
Location
US
I have a form that I select multiple files to plot data from. The form can have as many as five files selected to plot data from; each corresponds to a control txtFile1, txtFile2, etc. The cmdPLOT button on the form calls a report that contains the graph and is using a subroutine called DrawGraph(). I am trying to create the legend on the graph by referencing the txtFile name from the controls on the form, which are the full paths for the files that I wish to plot.

For i = 1 To NoFiles
Me.DrawWidth = 8
Me.DrawStyle = 0
'Legend Lines (left, top, right, bottom)
Me.Line (lngBorderLeft + intXAxisCategoryWidth + _ 4050, lngBorderTop + i * 300)-(lngBorderLeft + intXAxisCategoryWidth * 2 + 4000, lngBorderTop + i * 300), _
Choose(i Mod 5 + 1, vbBlack, vbMagenta, _ vbBlue, vbRed, vbGreen)

'Legend name placement
Me.CurrentY = Me.CurrentY - 100
Me.CurrentX = Me.CurrentX + 50
Me.FontSize = 12
Me.FontBold = True
'Print Legend names
strFileN = [Forms]![frmselectfiles]![txtFile & " i " &]
adhSplitPathA strFileN, strDrive, strPath, strFileName, strExt

Me.Print strFileName
Next i

I keep getting the same error, that it cannot find [Forms]![frmselectfiles][txtFile & "i" &]. If I hard code in [Forms]![frmselectfiles][txtFile1], it works fine for the one file, but it will not let me loop through all the controls to print all the file names.

Thanks for your help in advance.

BusMgr


 
Hi!

To use "dynamic" addressing/referencing, try:

[tt]strFileN = Forms("frmselectfiles")("txtFile" & i)[/tt]

Roy-Vidar
 
Thanks Roy-Vidar, but it still doesn't do it. Get the same error message. Any other ideas??
BusMgr
 
You might try:

trFileN = Forms("frmselectfiles").Controls("txtFile" & i)

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks. Works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top