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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters From A Form to VBA Code 1

Status
Not open for further replies.

ChiTownDiva

Technical User
Jan 24, 2001
273
US
Happy Monday All...

I have some code:

Function GoGet()


DoCmd.TransferText acImportFixed, "MGT/OWNER Import Specification", "MGMT", "C:\Documents and Settings\r60016\My Documents\Linkage\Supermarkets\Albertsons\Imports\MANAGEMENT.txt", False, ""
Beep
MsgBox "Management File Import Successful!", vbOKOnly, "MANAGEMENT"

End Function


What I want to do is pass a couple of parameters to this. Where in the code it says "C:\Documents and Settings\r60016\My Documents\Linkage\Supermarkets\Albertsons\Imports\MANAGEMENT.txt", I would like to pass a parameter:

C:\Documents and Settings\r60016\My Documents\Linkage\Channel\Store\Imports\MANAGEMENT.txt

from a form.

I couldn't really define the Channel and Store parameters within the code, there's over 50 channels and a few hundred stores.

Is this doable?

Thanks in advance for any assistance.

ChiTownDiva [ponytails]
 
Just a quick review...

'Call Function
Dim lcFile as String
lcFile = "C:\Temp\TempImport.txt"
GoGet lcFile


Function GoGet(lcFileAndPath as String)
Dim objFSO As New Scripting.FileSystemObject
'Be sure to enable Tools-References: MS Scripting Runtime library.

'Perhaps add check to see if file exists first!
'exit function if file not found.
If objFSO.FileExists(lcFileAndPath) = False Then
msgobx("File Not Found!")
Exit Function
End If


DoCmd.TransferText acImportFixed, "MGT/OWNER Import Specification", "MGMT", lcFileAndPath, False, ""
Beep
MsgBox "Management File Import Successful!", vbOKOnly, "MANAGEMENT"

End Function



Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
Something like this ?
DoCmd.TransferText acImportFixed, "MGT/OWNER Import Specification", "MGMT", "C:\Documents and Settings\r60016\My Documents\Linkage\" & Forms![your form]![Channel textbox] & "\" & Forms![your form]![Store textbox] & "\Imports\MANAGEMENT.txt", False, ""

Or (more general):
Sub GoGet(strChannel As String, strStore As String)
DoCmd.TransferText acImportFixed, "MGT/OWNER Import Specification", "MGMT", "C:\Documents and Settings\r60016\My Documents\Linkage\" & strChannel & "\" & strStore & "\Imports\MANAGEMENT.txt", False, ""
...
End Sub
and in the form:
Call GoGet(Me![Channel textbox], Me![Store textbox])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV...works like a charm!! [wiggle]

One star from me!

ChiTownDivaus [ponytails]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top