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

DoCmd.OutputTo causes run-time error 2024 or 2302

Error Resolution

DoCmd.OutputTo causes run-time error 2024 or 2302

by  PaulBricker  Posted    (Edited  )
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\"[blue] & myFile[/blue], 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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top