A2003: check if linked table, then make read-only

bulrush

Registered User.
Local time
Today, 12:56
Joined
Sep 1, 2009
Messages
209
I have a condition where if my main table is linked, I want to make it read-only. If it is local (in the same MDB file as the screen that is running) i want to make that table read-write.

What is the VBA code to do this? I couldn't find any help in Access help.
 
Well, this is what I got after some experimentation.
Code:
' A2003: is a table linked or a regular local table?
' May 2011
dim mydb as DAO.database
dim tname as string

Set mydb = CurrentDb()
tname="Mytable"
If (Len(mydb.TableDefs(tname).Connect) > 0) Then
    s = "ERROR: " & tname & " is linked. You cannot update a linked table."
    MsgBox (s)
    Exit Sub
End If
It seems to work.
 

Users who are viewing this thread

Back
Top Bottom