Prevent linking to system tables?

  • Thread starter Geezer via AccessMonster.com
  • Start date
G

Geezer via AccessMonster.com

I found some code, adjusted it a little, and although it seems to work, when
I exit the DB and open it next I get "Invalid Operation" (error 3219). If I
click OK nine times I get a message "Cannot Update. Database or Object is
read-only." Clicking OK takes me into the DB and everything seems fine from
there on. The code is attached to the OnClick of a command button and is
intended to search through the tables in the BE file, relink to the FE and if
there are any new tables in the BE that were not previously linked, to create
a link to the FE. As I said, it works, creating links to new tables, but
then I get the error messages above after exiting the FE and entering it next.
I "think" the problem is that the code is (or is trying to) link to the
system (MSYS?) tables in the BE. If that's the case, how can I adjust this
code so it ignores system tables? CboPath is a combobox used to select the
path to the BE, CboName is a combo to select which BE file to link to, and
TxtBackEndPath concatinates the two to represent the full path to the desired
BE file.

If (IsNull(Me.CboPath) Or IsNull(Me.CboName)) Then
MsgBox ("You must select the Path and TABLES file, with the two combo
boxes above, in which you wish to Link")
Else
Dim dbsFront As DAO.Database, dbsBack As DAO.Database
Dim tdfFront As DAO.TableDef, tdfBack As DAO.TableDef
Dim strTable As String


Dim strBackendPath As String
strBackendPath = Me.TxtBackEndPath

' return references to front and back ends
Set dbsFront = CurrentDb
Set dbsBack = OpenDatabase(strBackendPath)

For Each tdfBack In dbsBack.TableDefs
' check if link to table exists and if not create link
strTable = tdfBack.Name
On Error Resume Next
Set tdfFront = dbsFront.TableDefs(strTable)
If Err <> 0 Then
DoCmd.TransferDatabase acLink, _
"Microsoft Access", strBackendPath, _
acTable, strTable, strTable
End If
Err.Clear
Next tdfBack
End If

It's probably something simply, but it's beyond me ;-) Thanks for any
insight.
Tom
 
D

Douglas J. Steele

You can detect whether a table's a system table using:

If (tdfBack.Attributes And dbSystemObject) = 0 Then
' It's not a system object
Else
' It is a system object
End If
 
G

Geezer via AccessMonster.com

That did the trick!! Thanks very much.
You can detect whether a table's a system table using:

If (tdfBack.Attributes And dbSystemObject) = 0 Then
' It's not a system object
Else
' It is a system object
End If
I found some code, adjusted it a little, and although it seems to work,
when
[quoted text clipped - 53 lines]
insight.
Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top