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

Access 2007 crashes when .NET component called

Status
Not open for further replies.

DatabaseDude

Programmer
Nov 7, 2005
112
US
I have an Access 2007 application that "watches" a folder to determine if new files or added, or if existing files are renamed. This uses the .NET FileSystemWatcher class, incorporated into a DLL wrapper named IOLib.

I've downloaded all the code and made it work without error in a VB6 form: (scroll down to "Using the FileSystemWatcher from Visual Basic 6").

However, in Access 2007, the application crashes frequently upon any of the events firing. Lately it seems to have been much more stable on my Win XP Pro box, but it absolutely refuses to run on Vista Business.

Here's the form code (with the exception of the AttachPDF subroutine, which never gets called due to crashing):

Code:
Option Explicit
Option Compare Database

Private WithEvents fsw As IOLib.FileSystemWatcherWrapper

Private Sub Form_Load()       
    Set fsw = New IOLib.FileSystemWatcherWrapper
    With fsw
        .InitWatcher "c:\foldername"
        .IncludeSubDirectories = False
        .EnableRaisingEvents = True
    End With
End Sub

Private Sub fsw_Created(ByVal e As IOLib.FileSystemEventArgsWrapper)
    Dim strFileName As String
    
    strFileName = e.Name
    
    If Right(strFileName, 3) = "pdf" Then
        Call AttachPDF(e.Name, e.FullPath)
    End If
End Sub

Private Sub fsw_Changed(ByVal e As IOLib.FileSystemEventArgsWrapper)
    ' Do nothing
End Sub

Private Sub fsw_Deleted(ByVal e As IOLib.FileSystemEventArgsWrapper)
    ' Do nothing
End Sub

Private Sub fsw_Renamed(ByVal e As IOLib.FileSystemEventArgsWrapper)
    Dim strFileName As String
    
    strFileName = e.Name
    
    If Right(strFileName, 3) = "pdf" Then
        Call AttachPDF(e.Name, e.FullPath)
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set fsw = Nothing
End Sub

Any pointers? Thinking it's something with the WithEvents, but gone as far as I can at the moment.

Thanks much in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top