Napraviš novi modul i u njega ubaciš kod:
Code:
Function IsLinked(strTableName As String) As Boolean
'Purpose: check if tables are linked OK
'strTableName - any of linked tables
'Returns = tRUE if all is OK, FALSE if relinking is needed
'Example: ? IsLinked("tblRoba")
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim flgRetval As Boolean
On Error GoTo ERROR_HANDLER:
strSQL = "SELECT * FROM " & strTableName & " WHERE FALSE"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
flgRetval = True
EXIT_HERE:
IsLinked = flgRetval
Exit Function
ERROR_HANDLER:
Select Case Err.Number
Case 3024
'do nothing, no message!
'3024 is "Could not find the file ' ... where table strTableName is suposed to b
Case Else
MsgBox "IsLinked() ERROR " & Err.Number & vbCrLf & Err.Description
End Select
Resume EXIT_HERE
End Function
Zatim tu funkciju opozoveš recimo na OnOpen ulazne (logon) forme ili na neko dugme na formi, primer:
Code:
Private Sub Command0_Click()
If IsLinked("tblTABELA") Then
Call OpenForm("frmTABELA_koju pozivas")
Else
Call OpenForm("frmLinkovanje")
End If
DoCmd.Close acForm, Me.Name
End Sub
Pozdrav