Here is some code that I have in my code library which checks to see if a log file exists, I am sure you can modify it to your needs.  Compliments of Tobi Hoffman.
 

This is in a module as a public function.  Yes, I know it doesn't return anything, could be a Sub, but it works.

Tobi Hoffman – [EMAIL PROTECTED]

 

Function Instrumented(strError As String)

' Comments : Write all errors to a log file

' Parameters: strError-- string sent in error trap

'=============================================================

 

Dim strLog As String

Dim strUser As String

Dim strMsg As String

Dim intFile As Integer

 

strLog = "\\PathOnServer\AppErrorLog.log"

 

intFile = FreeFile()

If FileExists(strLog) Then

    Open strLog For Append As #intFile

Else

    Open strLog For Output As #intFile

End If

 

strUser = Nz(GetUserName,"Not logged in") ' whatever function you use to get a user name

' strMsg gives it a timestamp, user's name, then on next line, the error you sent.

strMsg = Now() & " " & strUser & vbCrLf & strError

Print #intFile, strMsg

Close intFile

 

End Function

 

Then in the error trap section of every module:

 

ErrorTrap:

 

    MsgBox Err.Description

    Instrumented "frmSites!cmdDelete_Click: " & Err.Description

    Resume Exit_cmdDelete_Click

 

End Sub

 

Dawn Crosier
Application Specialist
"Education Lasts a Lifetime"

 
This message was posted to a newsgroup.  Please post replies and questions to the group so that others can learn as well.



From: AccessDevelopers@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Trent Johnsey
Sent: Wednesday, January 11, 2006 9:45 PM
To: AccessDevelopers@yahoogroups.com
Subject: [AccessDevelopers] Verify File Exists

I have a situation where a needs to open an external file from an Access form.  However, the external file could be in one of 4 formats.  The file name will be set, but the file extension will vary.  The format could be Excel, Word, Acrobat, or html. 

My problem is i am not sure how to check to see if the file exists.  If the document exists, then I plan on opening the document using the shell command.  Everything is fine with this process.  However, I am running into issues determine if the file exists prior to opening it.  Any assistance would be appreciated.
thanks
TJ



Please zip all files prior to uploading to Files section.




SPONSORED LINKS
Microsoft access developer Microsoft access help Microsoft access database
Microsoft access training Microsoft access training course Microsoft access programming


YAHOO! GROUPS LINKS




Reply via email to