Save string as a text file

ghudson

Registered User.
Local time
Today, 04:37
Joined
Jun 8, 2002
Messages
6,193
Is it possible to save a "string" into a text file? If so, how can I do it with VBA for Access 97?

I have a custom error message that displays if the user has an unexpected (yet trapped) runtime error. I want to save the custom errors as a text file.

Dim sError as String
sError = "Testing 123"

'something yet not quite like this... ;)
Save sError as "C:\Errors\Test.txt"

Thanks in advance for your help.
 
Hi

Stick it in a module and call it as a function in your sub



ErrorPrint err.description


Public Function ErrorPrint(Msg As String)
Dim nfile As Integer

nfile = FreeFile

Open "C:\Errorlog.txt" For Append Shared As #nfile
Print #nfile, Now() & " - " & Msg
Close #nfile

End Function


Chris
 

Users who are viewing this thread

Back
Top Bottom