PDA

View Full Version : [SOLVED:] application.run function........ weird error



samuelimtech
09-03-2014, 07:01 AM
Hi first of all thanks for any help on this,


I have the following code being called from a button



Private Sub Export2JDE_Click()
Application.Run (JDE_Export)
End Sub


this calls the below function


Public Function JDE_Export()
Const FILE_PATH As String = "T:\Inter Urban\Consultancy Services\Timesheets\Templates\Access\"
Dim strFullPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, , "TempHours", strFullPath & "JDE.xlsx", False
End Function


ok now this is where it gets weird......everything works fine until the end function line of the code, the table has been succesfully exported, what is expected is for the function to end and return to the first code to End but im getting the error "Access cant find the procedure".

i havent got a clue whats wrong

ranman256
09-03-2014, 07:26 AM
Your 'function' is not really returning anything. Change it to a SUB.
usage:



Private Sub Export2JDE_Click()
JDE_Export
End Sub

Public sub JDE_Export()
Const FILE_PATH As String = "T:\Inter Urban\Consultancy Services\Timesheets\Templates\Access\"
Dim strFullPath As String
strFullPath = FILE_PATH
DoCmd.TransferSpreadsheet acExport, , "TempHours", strFullPath & "JDE.xlsx", False
End sub