Application.Filesearch in a Runtime program

  • Thread starter Thread starter Matt
  • Start date Start date
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
 
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
 
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
 
Back
Top