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

Sub vs Function procedure

Status
Not open for further replies.

atadbitslow

Programmer
Feb 26, 2001
301
US
Can someone help me with the distinction and where to put it?? See below for previously posted ques--thanks!

Is there a switch or another way to automatically overwrite a file if it already exists? I am using the output to command in a macro to output a report to Excel format with a given name, but I don't want the user to have to answer the overwrite questions??

Thanks!


RickSpr (MIS) Mar 26, 2001
Maybe the simplest way would be to write a VBA procedure to delete the file if it exists:
Public Sub DeleteFile(FilePath As String)
On Error Resume Next
Kill FilePath
End Sub

Then just insert a RunCode action with the Function Name set to: DeleteFile("C:\My Documents\My File.ext")
Rick Sprague


maddieboo (Programmer) Apr 2, 2001
Thanks Rick--I finally got around to doing this, but I got an error that said "The expression you entered has a function name that Access can't find."

I put the function under modules--is that correct? Should it be a public function instead of sub?

Thanks!


 
Hi Maddiboo, Rick's not in right now but he'd tell you to name that beauty a Public Function. Make sure it ends up saying "end function" too but it should do that automatically. :) Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top