I use code in the first form that checks to see if the drive is C:\ (local drive). dB MUST be opened from local computer (or "local" cloud computer)
If it is not the local C:\ drive, I display a message that says it must be opened from the local c drive, then closes the dB.
Code looks like this:
Code:
Private Sub Form_Open(Cancel As Integer)
Dim d As Database, r As Recordset ', s As Recordset
Dim Msg
Dim sDrive As String
On Error GoTo login_open_error
'check to see if the FE is on a non-networked drive
'Debug.Print CurrentDb.Name
sDrive = Left(CurrentDb.Name, 1)
' MsgBox sDrive
' "C" is local drive, "Z" is cloud drive (everyone's cloud is "Z". Cloud common drive is "H".
If sDrive <> "C" And sDrive <> "Z" Then
Msg = "This front end (FE) databse MUST be opened from a local drive." & vbNewLine & vbNewLine
Msg = Msg & "It cannot be started from a server (network) drive or a shortcut to a networked drive." & vbNewLine & vbNewLine
Msg = Msg & "PLEASE copy the FE to to a local drive and try again. "
MsgBox Msg
Quit (acQuitSaveNone)
Else
Set d = CurrentDb
'check to see if there is at least one linked table - linking to SQL Server Express
Set r = d.OpenRecordset("select cnd_pk from company_name_def", dbOpenDynaset, dbSeeChanges)
If IsNull(r.Fields(0)) Then
DoCmd.OpenForm "openerror"
Else
DoCmd.OpenForm "startup" 'main form name
DoCmd.Close acForm, Me.Name
End If
End If
login_open_exit:
On Error Resume Next
r.Close
Set r = Nothing
Set d = Nothing
Exit Sub
login_open_error:
Select Case Err.Number
Case 3078, 3024, 3044 ' table not there
MsgBox "The data files are not available. Please locate the Back End Database now."
btnSelectBE_Click
Case 3622
DoCmd.OpenForm "startup"
DoCmd.Close acForm, Me.Name
'Resume login_open_exit
Case Else
MsgBox Err.Number & ": " & Err.Description
Resume login_open_exit
End Select
End Sub