Application.Filesearch in a Runtime program

M

Matt

I have an application that works fine on my development machine. It has
Access 2003. However, when I package it up into a runtime application, there
is a part of the code that doesn't seem to work and I can't figure out what
I'm missing to make it work for the runtime version. Everything seems to
work fine, but this part of the code never discovers the file and I'm
positive that the file exists where it is supposed to. The code is below.
Am I possibly missing some reference files or something? It appears to be
installing Runtime Version 2002 when I run the install package. Thanks in
advance.

Private Sub Form_Timer()
'searches for DataBaseOn.txt every minute.
'if not found, quits Access
Dim fs
Set fs = Application.FileSearch

With fs
.NewSearch
.LookIn = "\\Srvrghq\inventory"
.SearchSubFolders = False
.FileName = "DataBaseOn.txt"
If .Execute = 0 Then
'display a form with a message
DoCmd.OpenForm "frmClock", , , , , acDialog
'get out
Application.Quit

End If
End With

End Sub
 
K

Klatuu

It is most likely a reference issue in VBA, but for what you are doing, a
filesearch is massive overkill. All you really need is the Dir function:

Private Sub Form_Timer()
'searches for DataBaseOn.txt every minute.
'if not found, quits Access

If Dir(\\Srvrghq\invinventory\DataBaseOn.txt) = vbNullString Then
'display a form with a message
DoCmd.OpenForm "frmClock", , , , , acDialog
'get out
Application.Quit
End If

End Sub
 
M

Matt

Thanks you so much. That solved my problem.

Klatuu said:
It is most likely a reference issue in VBA, but for what you are doing, a
filesearch is massive overkill. All you really need is the Dir function:

Private Sub Form_Timer()
'searches for DataBaseOn.txt every minute.
'if not found, quits Access

If Dir(\\Srvrghq\invinventory\DataBaseOn.txt) = vbNullString Then
'display a form with a message
DoCmd.OpenForm "frmClock", , , , , acDialog
'get out
Application.Quit
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top