Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just wanted to say that you guys RULE, a million thank you's to whoever created, and/or manages this site. KEEP UP THE GOOD WORK..."

Geography

Where in the world do Tek-Tips members come from?

Microsoft: Access Modules (VBA Coding) FAQ

Error Resolution

DoCmd.OutputTo causes run-time error 2024 or 2302
Posted: 19 May 06

After sweating over this problem and not getting anywhere with search, I found the solution is almost as simple as MS describes in their Knowledge Base article.  

M$'s example to duplicate the problem

CODE

Sub OutputSnapshot()
   DoCmd.OutputTo acOutputReport, "Alphabetical List of Products", acFormatSNP, "C:\My Documents\", True
End Sub
    

What they don't explain is you need to add the file name to the OutPutFile argument.  You can either hard code the name, or you can use a variable if you want to assign different names each time your run the code.  In this example, I change the name of the .snp file by assigning the current date to the name.

CODE

Sub OutputSnapshot()
Dim myFile as String

     myFile = "SomeName" & Format(Date(),"mmddyy") & ".snp"
   DoCmd.OutputTo acOutputReport, "Alphabetical List of Products", acFormatSNP, "C:\My Documents\" & myFile, True
End Sub
One hint is to make sure you don't have any invalid characters in the file name which is why my example takes the / out of the date format.
HTH

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close