Macro to run VBA Code

wjburke2

Registered User.
Local time
Today, 15:29
Joined
Jul 28, 2008
Messages
194
I am creating a application to import a Excel worksheet and export a text file. I want the application to run when the user clicks a ICON on their desktop. I was trying to code a Macro using the RunCode action.
When I try to put in the function name I get the error "The expression you entered has a function name that Microsoft Office Access can't find". In the pull down it shows the miodules but not functions. It will not allow me to select the function or the module. Here is my code.

Module MarginRankImport


Private Function ImportMarginRanking()
FileName = GetFileName("Select the Margin File", "C\MarginRankApp\")
If FileName = "" Then GoTo Exit_ImportMarginRanking

FromPath = Left(FileName, InStrRev(FileName, "\"))

MsgBox "Importing records - Please wait", vbExclamation

DoCmd.RunSavedImportExport "Import-Margin Rank Assignment"

ConvertAMR

DoCmd.SetWarnings False

DoCmd.RunSQL "delete * from [ExportMarginRank]"
DoCmd.OpenQuery "ExportMarginRank Query"

DoCmd.SetWarnings True

ExpSpec = "MarginRank Export Specification"
TableName = "ExportMarginRank"
FileName = "MarginRank.txt"
DoCmd.TransferText acExportFixed, ExpSpec, TableName, FromPath &
FileName

Exit_ImportMarginRanking:

End Function
 
Last edited:
In the builder you have to click on the module name and then it would show up, but ONLY if it is a FUNCTION (not a SUB). If you have a sub, you will need to change it to a function to be available this way (you probably also need to have it be a PUBLIC function).
 
Bob, you have did it again. Making it a public function instead of a Private function worked great. Thank you.
 

Users who are viewing this thread

Back
Top Bottom