Could someone please have a look at this code and identify why it might not work in some situations. I have a client who doesn't have a C drive but has an N drive in a network situation. This code which is in my start up form isn't prompting for a relink......works fine for me.....
On Error GoTo Err_Form_Open
Dim strTest As String, DB As DAO.Database
Dim td As DAO.TableDef
Set DB = CurrentDb
For Each td In DB.TableDefs
If Len(td.Connect) > 0 Then
On Error Resume Next
strTest = Dir(Mid(td.Connect, 11))
On Error GoTo Err_Form_Open
If Len(strTest) = 0 Then
If MsgBox("Couldn't find the data file " & Mid(td.Connect, 11) & ". Please choose the location of the data file.", vbExclamation + vbOKCancel + vbDefaultButton1, "Can't find data file") = vbOK Then
DoCmd.OpenForm "frmNewDataFile"
DoCmd.Close acForm, Me.Name
Exit Sub
Else
MsgBox "This application will now be shutdown.", vbExclamation, "Procedure Aborted"
DoCmd.Quit
End If
End If
End If
Next
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frm Password"
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Err.Number & ":" & Error.Description
Resume Exit_Form_Open
Thankyou kindly to those that have a squiz!
Rachael
On Error GoTo Err_Form_Open
Dim strTest As String, DB As DAO.Database
Dim td As DAO.TableDef
Set DB = CurrentDb
For Each td In DB.TableDefs
If Len(td.Connect) > 0 Then
On Error Resume Next
strTest = Dir(Mid(td.Connect, 11))
On Error GoTo Err_Form_Open
If Len(strTest) = 0 Then
If MsgBox("Couldn't find the data file " & Mid(td.Connect, 11) & ". Please choose the location of the data file.", vbExclamation + vbOKCancel + vbDefaultButton1, "Can't find data file") = vbOK Then
DoCmd.OpenForm "frmNewDataFile"
DoCmd.Close acForm, Me.Name
Exit Sub
Else
MsgBox "This application will now be shutdown.", vbExclamation, "Procedure Aborted"
DoCmd.Quit
End If
End If
End If
Next
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frm Password"
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Err.Number & ":" & Error.Description
Resume Exit_Form_Open
Thankyou kindly to those that have a squiz!
Rachael