Sandra Smith
asked on
Looping through two arrays in a nested for statement
I have a process where users can select one or more documents to archive. They also have the option of changing the name, however, if they do this, I need to pass both the original name as well as the new name to the procedure for a file copy. I have two text boxes, one holds the "new" name and the other holds the "orignal" name. So what I need is if the user, say for document 3, they change the name, I need the procedure to grab the corresponding original name from the "original" text box so it knows which file to copy. The "new" textbox and the "original" name texbox are in tandem, that is, the positions of the items are the same in both so item 3 in both arrays refer to the same document. As the loop goes through the array, I need both the strOriginalDocName as well as teh strSaveDocName to be passed to the RecordArchive procedure.
Dim arrArchive() As String
Dim arrOriginal() As String
Dim i As Integer
arrArchive = Split(Me.txtDocument, ",")
arrOriginal = Split(Me.txtOriginalName, ",")
For i = 0 To UBound(Arr)
strSaveDocName = arrArchive(i) & "_" & Me.txtEmpFRBEmployeeNumber
strOriginalDocName = arrOriginal(i) & "_" & Me.txtEmpFRBEmployeeNumber
'Check to see if file already exists in destination folder
If fntFileExists(strPath & strSaveDocName) Then
varResponse = MsgBox("This file exists already, do you wish to overwrite?" & vbCrLf & _
"If not, hit No so you can change the document name " & vbCrLf & _
"or simply close the form.", vbYesNo)
If varResponse = 7 Then 'vbYesNo are really integer return values
Me.txtDocument.SetFocus
Exit Sub
Else
Call RecordArchive(strDir, strOriginalDocName, strPath, strSaveDocName, True)
End If
Else
Call RecordArchive(strDir, strOriginalDocName, strPath, strSaveDocName, False)
End If
Next i
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sandra