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

Create Journal ??

Status
Not open for further replies.

ddmtn546

Technical User
Dec 20, 2000
38
US
Being a utility, I have a created a DB to track incoming customer outage reports. All works well, however, I also desire a means to create a "scratch-pad" for an operator to input other significant events. Upon completion of message, Access to write system date/time with operator message to a journal. Can Access perform this function? Would I have to output to file in MSWord? Can this file be appendable? Any thoughts or ideas would be appreciated. Thanks in advance.
 
hi,

maybe you'll find your answer in the following function:

Private Function gf_Schrijf_Log(str_dossier As String, str_fout As String)
Dim str_sourcefilename As String
Dim str_record As String * 153
Dim rcs_a As Recordset
Dim str_logfile As String
Dim str_dos As String
Dim int_i%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, f, ts


On Error GoTo err_schrijf_log

str_sourcefilename = Left(CurrentDb.Name, Len(CurrentDb.Name) - 8) & "log.txt"


Set fs = CreateObject("Scripting.FileSystemObject")
file_gecreeerd:
Set f = fs.getfile(str_sourcefilename)
Set ts = f.openastextstream(ForAppending)

str_record = ""
Mid(str_record, 1, 150) = str_dossier

ts.write str_record & vbCrLf

For int_i = Len(str_dossier) To 0 Step -1
If Mid(str_dossier, int_i, 1) <> &quot;\&quot; Then
str_dos = Mid(str_dossier, int_i, 1) & str_dos
Else
int_i = 0
End If
Next int_i
str_record = &quot;&quot;
Mid(str_record, 1, 80) = str_dos
Mid(str_record, 81, 20) = CurrentUser
Mid(str_record, 102, 20) = Now()

ts.write str_record & vbCrLf

str_record = &quot;&quot;
ts.write str_fout & vbCrLf

ts.Close
Set ts = Nothing
Set f = Nothing

Exit Function
err_schrijf_log:
Select Case Err.Number
Case 53
Set f = fs.CreateTextFile(str_sourcefilename)
Set f = fs.getfile(str_sourcefilename)
Set ts = f.openastextstream(ForAppending)
ts.write &quot;logfile&quot; & vbCrLf
ts.Close
Resume file_gecreeerd
End Select

End Function
 
Thanks karateKid, being a novice VB guy, do I create a module and how is it referenced? I have, as yet, created a control on any form for the data entry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top