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

Write to a file? Then print a file... 1

Status
Not open for further replies.

darkhat01

IS-IT--Management
Apr 13, 2006
144
US
I have an Access database that opens up and runs the VB code, this is all it does. I did not write this database, as you will be able to tell from my question. This database copies 15 other databases into one database everyday.

The problem is that for every database that it copied it brings up a message box telling me if it was successful or not.

What I would like to do is not have the message box come up, but instead write this message to one text file (log file) for all 15 messages, then print the file and close the database. I understand how to close the database. But writing to a file and printing I have no idea. The Printer is a networked printer.

I should only have to replace the MsgBox with a command to write to a file correct? Any help pointing me in the right direction would be great.

Thanks,

Darkhat01
 
The easiest thing to do is probably to create a table of errors and then print a report fron this table. All the tools to do this are readily available.
 
Well Remou has a strong point!

But if you 'd like a simple log to write to with been able to check while a process is running and logging

Code:
Option Explicit
Dim fso As Object 'Scripting.FileSystemObject
------------------
Sub Start
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.CopyFile "C:\my.txt", "C:\my.log", True
.....
End sub
------------------
Sub Logg(my_Text As String)
Dim TheFile As Object 'Scripting.TextStream

    Set TheFile = fso.OpenTextFile("C:\my.log", 8) 'ForAppending
    my_Text = Format(Date, "dd/mm/yyyy") & Chr(124) & Format(Time, "hh:mm:ss") & Chr(124) & my_Text
    TheFile.writeline (my_Text)
    TheFile.Close
    Set TheFile = Nothing

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top