I have searched several times for a solution to this problem, but can't seem to figure out what the issue is. I have code (copied from here and the MS-Access how to) that has a hidden form that loads on the db startup. Attached to that form is code that is supposed to check for a file, if the file is found, nothing happens. If the file is not found, then it starts a timer and shuts down the front end of every user that has it opened.
The problem I have is that the code doesn't seem to "see" the file regardless of whether or not it is named the correct/incorrect name. The file that it is supposed to look for is in the same folder, on the network, that the database front end is in.
I have tried "\\blah\blah\txtTest.ozx" and "s:\...\txtTest.ozx" but neither way seems to work.
We are using Access 2010.
Any insights/help are greatly appreciated.
The problem I have is that the code doesn't seem to "see" the file regardless of whether or not it is named the correct/incorrect name. The file that it is supposed to look for is in the same folder, on the network, that the database front end is in.
I have tried "\\blah\blah\txtTest.ozx" and "s:\...\txtTest.ozx" but neither way seems to work.
Code:
Option Explicit
Dim boolCountDown As Boolean
Dim intCountDownMinutes As Integer
Private Sub Form_Open(Cancel As Integer)
' Set Count Down variable to false
' on the initial opening of the form.
boolCountDown = False
Dim strFileName As String
strFileName = Dir("S:\folder\folder\folder\txtTest.ozx")
If strFileName <> "txtTest.ozx" Then
MsgBox "Database being updated, please try again later."
Application.Quit acQuitSaveAll
End If
End Sub
Private Sub Form_Timer()
On Error GoTo Err_Form_Timer
Dim strFileName As String
strFileName = Dir("S:\folder\folder\folder\txtTest.ozx")
If boolCountDown = False Then
' Do nothing unless the check file is missing.
If strFileName <> "txtTest.ozx" Then
' The check file is not found so
' set the count down variable to true and
' number of minutes until this session
' of Access will be shut down.
boolCountDown = True
intCountDownMinutes = 2
End If
Else
' Count down variable is true so warn
' the user that the application will be shut down
' in X number of minutes. The number of minutes
' will be 1 less than the initial value of the
' intCountDownMinutes variable because the form timer
' event is set to fire every 60 seconds
intCountDownMinutes = intCountDownMinutes - 1
DoCmd.OpenForm "frmAppShutDownWarn"
Forms!frmAppShutDownWarn!txtWarning = "This application will be shut down in approximately " & intCountDownMinutes & " minute(s). Please save all work."
If intCountDownMinutes < 1 Then
' Shut down Access if the countdown is zero,
' saving all work by default.
Application.Quit acQuitSaveAll
End If
End If
Exit_Form_Timer:
Exit Sub
Err_Form_Timer:
Resume Next
End Sub
We are using Access 2010.
Any insights/help are greatly appreciated.