473,408 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Logfile

Hello,

is anyone willing to help me out to setup a logfile.
I have a program running in Access, but I want to know the progress of
it.
It is rather easy I think, but don't know how to handle it.
Basicly, I run macros and I just want to write a message to a file
before and after the run of that macro.
eg:

Write Date(), Time(),"Start" & "message 1" to logfile.txt
run macro1
Write Date(), Time(),"Stop" & "message 1" to logfile.txt
Write Date(), Time(),"Start" & "message 2" to logfile.txt
run macro2
Write Date(), Time(),"Stop" & "message 2" to logfile.txt
Write Date(), Time(),"Start" & "message 3" to logfile.txt
run macro3
Write Date(), Time(),"Stop" & "message 3" to logfile.txt
Who can help me out? Tnx.

Oct 5 '06 #1
6 6859
ro***************@gmail.com wrote:
Hello,

is anyone willing to help me out to setup a logfile.
I have a program running in Access, but I want to know the progress of
it.
It is rather easy I think, but don't know how to handle it.
Basicly, I run macros and I just want to write a message to a file
before and after the run of that macro.
eg:

Write Date(), Time(),"Start" & "message 1" to logfile.txt
run macro1
Write Date(), Time(),"Stop" & "message 1" to logfile.txt
Write Date(), Time(),"Start" & "message 2" to logfile.txt
run macro2
Write Date(), Time(),"Stop" & "message 2" to logfile.txt
Write Date(), Time(),"Start" & "message 3" to logfile.txt
run macro3
Write Date(), Time(),"Stop" & "message 3" to logfile.txt
Who can help me out? Tnx.
Some code straight out of help.

Open "TESTFILE" For Output As #1 ' Open file for output.
Print #1, "This is a test" ' Print text to file.
Print #1, ' Print blank line to file.
Print #1, "Zone 1"; Tab ; "Zone 2" ' Print in two print zones.
Print #1, "Hello" ; " " ; "World" ' Separate strings with space.
Print #1, Spc(5) ; "5 leading spaces " ' Print five leading spaces.
Print #1, Tab(10) ; "Hello" ' Print word at column 10.

' Assign Boolean, Date, Null and Error values.
Dim MyBool, MyDate, MyNull, MyError
MyBool = False : MyDate = #February 12, 1969# : MyNull = Null
MyError = CVErr(32767)
' True, False, Null, and Error are translated using locale settings of
' your system. Date literals are written using standard short date
' format.
Print #1, MyBool ; " is a Boolean value"
Print #1, MyDate ; " is a date"
Print #1, MyNull ; " is a null value"

Print #1, MyError ; " is an error value"
Close #1 ' Close file.
Oct 5 '06 #2

maybe I didn't expressed well what I had in mind.
The issue is that I just want to find a way to fill up the log file
with messages generated as the process flows.
Every time I think it is necessary (predefined positions), I would like
to write to the log file by activating a procedure that just needs the
name of the process and some text as parameter; something like: Run
logging, "Message 1".
In the procedure the message is written to the logfile and added with a
Date and Time.

Can this be done easily?

Oct 5 '06 #3
ro***************@gmail.com wrote:
maybe I didn't expressed well what I had in mind.
The issue is that I just want to find a way to fill up the log file
with messages generated as the process flows.
Every time I think it is necessary (predefined positions), I would like
to write to the log file by activating a procedure that just needs the
name of the process and some text as parameter; something like: Run
logging, "Message 1".
In the procedure the message is written to the logfile and added with a
Date and Time.

Can this be done easily?
You asked how to send some text to write to a log file.

I provided an example. I recommend you run it. See the results.

It can be done easily.

You did not understand the code provided.

The question is...can you program?

Also, look at RunCode in help.

Oct 5 '06 #4
Dear Salad,

indeed, I'm not a programmer at all. I used to write programs in Dbase.
There I had the possibillity to run a program with extra parameters.
Via this program, and parameters, similar to what your wrote out for
me, the result came as easy as you tell it so well.
The problem is, How can I activate the code in the module and where do
I write my parameter.

By the way, find some code I used in a form where the procedure runs on
the on load event.
This is working well but the question remain. How can I fill my
variable "logentry" from outside??

Option Compare Database
Dim StrPath As String

Private Sub Form_Load()
Dim fn As Integer
fn = FreeFile
StrPath = "I:\be\_agb\Agfaproj\Logistiek\WOS"
logentry = "Testing to write to the logfile"
Open StrPath & "\WOS_Logging.txt" For Append As #fn
Write #fn, Now & ": " & logentry
Close #fn

End Sub
salad schreef:
salad schreef:
ro***************@gmail.com wrote:
maybe I didn't expressed well what I had in mind.
The issue is that I just want to find a way to fill up the log file
with messages generated as the process flows.
Every time I think it is necessary (predefined positions), I would like
to write to the log file by activating a procedure that just needs the
name of the process and some text as parameter; something like: Run
logging, "Message 1".
In the procedure the message is written to the logfile and added with a
Date and Time.

Can this be done easily?
You asked how to send some text to write to a log file.

I provided an example. I recommend you run it. See the results.

It can be done easily.

You did not understand the code provided.

The question is...can you program?

Also, look at RunCode in help.
Oct 5 '06 #5
ro***************@gmail.com wrote:
Dear Salad,

indeed, I'm not a programmer at all. I used to write programs in Dbase.
There I had the possibillity to run a program with extra parameters.
Via this program, and parameters, similar to what your wrote out for
me, the result came as easy as you tell it so well.
The problem is, How can I activate the code in the module and where do
I write my parameter.
See code below. Hmmm...oftentimes you exectute an action by pressing on
a command button...or some other event that you want to start the process.

If you are using a macro, and a command button, in the OnClick event
enter the name of the Macro. Or use VBA.

DoCmd.RunMacro "Macro1"

>
By the way, find some code I used in a form where the procedure runs on
the on load event.
This is working well but the question remain. How can I fill my
variable "logentry" from outside??
Oftentimes you declare a field on a form (you can make invisible if you
don't want it seen). Then
Write #fn, Now & ": " & Me.logentry

Or maybe you declared the variable as public under the Option Explicit
line at the top of the code module.

Option Compare Database
Option Explicit
Dim logentry as String

What/when you assign to logentry is up to you.

Option Compare Database
Dim StrPath As String

Private Sub Form_Load()
Dim fn As Integer
fn = FreeFile
StrPath = "I:\be\_agb\Agfaproj\Logistiek\WOS"
logentry = "Testing to write to the logfile"
Open StrPath & "\WOS_Logging.txt" For Append As #fn
Write #fn, Now & ": " & logentry
Close #fn

End Sub
What I might do is:
Open up a code module. Make a public sub that gets a message. Ex:
Public Sub WriteLog(strMsg As String, blnBlank As Boolean)
Open "LogFile" For Output As #1 ' Open file for output.
'print the message
Print #1, Date(); Tab ; Time() ; Tab ; _
IIF(Not blnBlank,"Start ","End ") & strMsg
'if this is the stop line, print a blank line
If blnBlank then Print #1,
Close #1 ' Close file.
End Sub

I am assuming you are using macros.
Now, in your macro, you call this code with RunCode. Or use VBA from
above to call WriteLog and then the macro
'Write Date(), Time(),"Start" & "message 1" to logfile.txt
Runcode WriteLog("Message 1",False)

run macro1

'Write Date(), Time(),"Stop" & "message 1" to logfile.txt
Runcode WriteLog("Message 1",True)

'Write Date(), Time(),"Start" & "message 2" to logfile.txt
Runcode WriteLog("Message 2",False)
etc

Not sure what message you pass to the routine via RunCode. You might be
better off just writing the whole thing in VBA. Like
Private Sub Command1_Click()
'uses routing blow this code block
WriteLog "Message variable", False
Docmd.RunMacro "Macro1"
WriteLog "Message variable", True
....
End Sub


>

salad schreef:
salad schreef:

>>ro***************@gmail.com wrote:

>>>maybe I didn't expressed well what I had in mind.
The issue is that I just want to find a way to fill up the log file
with messages generated as the process flows.
Every time I think it is necessary (predefined positions), I would like
to write to the log file by activating a procedure that just needs the
name of the process and some text as parameter; something like: Run
logging, "Message 1".
In the procedure the message is written to the logfile and added with a
Date and Time.

Can this be done easily?

You asked how to send some text to write to a log file.

I provided an example. I recommend you run it. See the results.

It can be done easily.

You did not understand the code provided.

The question is...can you program?

Also, look at RunCode in help.

Oct 5 '06 #6
Dear Salad,

now you are writing real stuff; thank you very much.
The last part, to write the hole thing in VBA seems to me the most
apropriate.

Again, thank you for the advise and the attention to my problem.

Good luck, Roger
What I might do is:
Open up a code module. Make a public sub that gets a message. Ex:
Public Sub WriteLog(strMsg As String, blnBlank As Boolean)
Open "LogFile" For Output As #1 ' Open file for output.
'print the message
Print #1, Date(); Tab ; Time() ; Tab ; _
IIF(Not blnBlank,"Start ","End ") & strMsg
'if this is the stop line, print a blank line
If blnBlank then Print #1,
Close #1 ' Close file.
End Sub

I am assuming you are using macros.
Now, in your macro, you call this code with RunCode. Or use VBA from
above to call WriteLog and then the macro
'Write Date(), Time(),"Start" & "message 1" to logfile.txt
Runcode WriteLog("Message 1",False)

run macro1

'Write Date(), Time(),"Stop" & "message 1" to logfile.txt
Runcode WriteLog("Message 1",True)

'Write Date(), Time(),"Start" & "message 2" to logfile.txt
Runcode WriteLog("Message 2",False)
etc

Not sure what message you pass to the routine via RunCode. You might be
better off just writing the whole thing in VBA. Like
Private Sub Command1_Click()
'uses routing blow this code block
WriteLog "Message variable", False
Docmd.RunMacro "Macro1"
WriteLog "Message variable", True
....
End Sub
Oct 6 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leader | last post by:
Hi, I want to take backup of database logfile periodically and automatically. What should i do then..... Thanks Hoque
0
by: guf | last post by:
Hi All, I have SQL Server 2000 sp3, Windows 2000 Server. I have a database which is used by an application server. I do several important jobs a day in the application server and never access my...
1
by: FJ | last post by:
Hi all, I hope someone can help me with the following: I want my database to make a logfile in which it puts the date and time a code is used. The code is triggered by a timer. Every x mins it...
3
by: ZoombyWoof | last post by:
HI all. I would like the same behaviour on the Microsoft Firewall logfile that you have on logfiles under unixes, you can make them rotate so that once a week or once a day the system renames the...
2
by: ge_orgy | last post by:
Accidently, I(we) deleted the Logfile.LDF in sysfiles folder on the mssql server and now can't enter the database, which status now is set SUSPECT. Before deleting the logfile I did a...
2
by: Andi Clemens | last post by:
Hi, we had some problems in the last weeks with our mailserver. Some messages were not delivered and we wanted to know why. But looking through the logfile is a time consuming process. So I...
0
by: indiarocks | last post by:
Is there a way in which the all the logging done using pexpect can be sent to stdout as well as a file. eg. filea = file('output.log',"w") ssh = pexpect.spawn('ssh root@1.1.1.1') ssh.logfile...
0
by: Adam | last post by:
Hello, I have a small app I am creating to crawl a directory and check that if it is moved to another a location it's path will not break a character limit. Usually the Windows path limit. ...
2
by: pompom | last post by:
hello all! i have to make a project for school , making a newsserver and a client. the thing is, i send messages between them to let the user know if everything is running ok. just some simple...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.