INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Error Resolution

DoCmd.OutputTo causes run-time error 2024 or 2302 by PaulBricker
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

Resources

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