Solved

err Log in a txt file

Posted on 1998-11-29
7
165 Views
Last Modified: 2010-05-03
I need A function so that if I call the function and it records/post the string to the last entry of the textfile specified in the pathname.

Private Function(PathName as string,ErrText as string)

 
if the function were called 4 times, A further example

Private Function("c:/err/err.txt","err1")
Private Function("c:/err/err.txt","err2")
Private Function("c:/dd/other.txt","otherfile")
Private Function("c:/err/err.txt","err3")

the resulting file err.txt would look like in c:/err/
err1
err2
err3

the resulting file other.txt would look like in c:/dd/
otherfile

if file exists in dir it would append the text
if file is not found in dir then a new one must be created.
The file should be closed and saved after.

I need the complete working code for this Function

Thank you.




0
Comment
Question by:vern123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 

Author Comment

by:vern123
ID: 1447312
Edited text of question
0
 

Author Comment

by:vern123
ID: 1447313
Edited text of question
0
 

Author Comment

by:vern123
ID: 1447314
Edited text of question
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
MikeP090797 earned 220 total points
ID: 1447315
Function Log(szFile as string, szMessage as string)
  Dim n as long
  n = freefile
  Open szFile for Append as #n
  Print #N, szMessage
  Close #N
End Function
0
 

Author Comment

by:vern123
ID: 1447316
Thanks mike, but I also need the function to add the file
(If it does not already exist) with the correct name/path
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1447317
It does that. The Append file access method creates the file if it doesn't exist already.
0
 

Author Comment

by:vern123
ID: 1447318
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question