Pass memory viarible to another sub

  • Thread starter Thread starter Song Su
  • Start date Start date
S

Song Su

To simplify my code, I plan to move 'DoCmd...." into another sub called
CleanUp.
memory viarible strPath is not working in CleanUp sub.
How do I fix it?
Thanks.

Private Sub cmdFall_Click()
Dim strPath As String
strPath = "s:\data\studFall.txt"
DoCmd.TransferText acImportFixed, "IDTransferSpec", "IDTransfer",
strPath, False, ""
Call CleanUp
End Sub
 
To simplify my code, I plan to move 'DoCmd...." into another sub called
CleanUp.
memory viarible strPath is not working in CleanUp sub.
How do I fix it?
Thanks.

Private Sub cmdFall_Click()
Dim strPath As String
strPath = "s:\data\studFall.txt"
DoCmd.TransferText acImportFixed, "IDTransferSpec", "IDTransfer",
strPath, False, ""
Call CleanUp
End Sub

Pass it as a string variable:

Call Cleanup(strPath)


or even leave strPath out of the Click code entirely and just use

Call Cleanup("s:\data\studFall.txt")

In the definition of sub Cleanup use


Public Sub CleanUp(strPath As String)
....
<code using strPath>
....
End Sub

You can then call CleanUp from many different places with many different paths
as needed.

John W. Vinson [MVP]
 
Back
Top