473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Don't link to system tables in backend

My front-end code manually links to the backend file.

I was wondering what stops Access from linking to the system tables in the
backend file. Is it just by virtue that they are hidden?

This has recently come up because I've been playing around with converting my
front end to A2003 format. At some point, I had a corruption issue with a
system file MSStorage something. Access kept saying it couldn't find it.
When I looked in the db Window I could see a link to it.

So I ran the code that deletes all links and then restarted my app. At
startup the app recreates all links. That solved the corruption problem.
But it got me thinking about the linking to backend system files.

Should I explicitly include VB Code that prevents linking to system tables
(and maybe other tables that I'm not aware of) contained in the backend.

Thanks.

--
Message posted via http://www.accessmonster.com

Aug 6 '06 #1
13 4867
rdemyan via AccessMonster.com wrote:
My front-end code manually links to the backend file.

I was wondering what stops Access from linking to the system tables
in the backend file. Is it just by virtue that they are hidden?

This has recently come up because I've been playing around with
converting my front end to A2003 format. At some point, I had a
corruption issue with a system file MSStorage something. Access kept
saying it couldn't find it. When I looked in the db Window I could
see a link to it.

So I ran the code that deletes all links and then restarted my app.
At startup the app recreates all links. That solved the corruption
problem. But it got me thinking about the linking to backend system
files.

Should I explicitly include VB Code that prevents linking to system
tables (and maybe other tables that I'm not aware of) contained in
the backend.

Thanks.
I don't have it handy to check, but I'm pretty sure that the
auto-linking/refreshing code that is frequently recommended in these groups does
have logic to specifically skip the system tables.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 6 '06 #2
I looked at the relinking code on the mvps site and didn't see anything that
popped out at me. I'm only an intermediate level programmer so maybe I
missed it.

So checked the option to show hidden tables and system tables in my backend
file and then launched my front end. I then looked in the dbWindow on my
front end.

I can see the system tables "grayed out". However there are no arrows on the
left hand side indicating that they are linked, except for MSysAccessXML..
However, this system table has showed up as linked in my front end for months.
Even when I delete the link it reappears. It hasn't seemed to cause a
problem, yet.


Rick Brandt wrote:
>My front-end code manually links to the backend file.
[quoted text clipped - 17 lines]
>>
Thanks.

I don't have it handy to check, but I'm pretty sure that the
auto-linking/refreshing code that is frequently recommended in these groups does
have logic to specifically skip the system tables.
--
Message posted via http://www.accessmonster.com

Aug 6 '06 #3
rdemyan via AccessMonster.com wrote:
I looked at the relinking code on the mvps site and didn't see
anything that popped out at me. I'm only an intermediate level
programmer so maybe I missed it.

So checked the option to show hidden tables and system tables in my
backend file and then launched my front end. I then looked in the
dbWindow on my front end.

I can see the system tables "grayed out". However there are no
arrows on the left hand side indicating that they are linked, except
for MSysAccessXML.. However, this system table has showed up as
linked in my front end for months. Even when I delete the link it
reappears. It hasn't seemed to cause a problem, yet.
Okay I had a look to remind myself how it works. The code loops through and
recreates the links of existing linked tables. Therefore local tables (such as
the system tables) are automatically skipped.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 6 '06 #4
Okay I had a look to remind myself how it works. The code loops through and
recreates the links of existing linked tables. Therefore local tables (such as
the system tables) are automatically skipped.
How did it get linked then?

Aug 6 '06 #5
"Lyle Fairfield" <ly***********@aim.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>Okay I had a look to remind myself how it works. The code loops through and
recreates the links of existing linked tables. Therefore local tables (such
as
the system tables) are automatically skipped.

How did it get linked then?
How did what get linked? His system table? I have no idea. I don't know if we
have even established that he is using the same code. The code I use loops
through existing links skipping ODBC links. I'm not positive that it's based on
the code at the MVPS.Org site, but that is my recollection.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 6 '06 #6
Rick Brandt wrote:
"Lyle Fairfield" <ly***********@aim.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Okay I had a look to remind myself how it works. The code loops through and
recreates the links of existing linked tables. Therefore local tables (such
as
the system tables) are automatically skipped.
How did it get linked then?

How did what get linked? His system table? I have no idea.
In another thread he identified the linked table as MSysAccessStorage.

In Access 2003 (I believe the OP is using Access 2003) when I try to
link to MSysAccessStorage in another db, the linked table is named
MSysAccessStorage1 by default. I haven't been able to rename it to
MSysAccessStorage.

Aug 6 '06 #7
This damned MSysAccessStorage table keeps getting linked to my front end. I
don't know why. It's the only system table that keeps getting linked. I
delete it and then my code seems to be relinking it but no other system
tables.

Oh, and it's currently only happening with my app on one computer but not on
my other computer. Exact same front end??!

This file is causing an error to occur on startup.

Lyle Fairfield wrote:
>Okay I had a look to remind myself how it works. The code loops through and
recreates the links of existing linked tables. Therefore local tables (such
[quoted text clipped - 4 lines]
>>
How did what get linked? His system table? I have no idea.

In another thread he identified the linked table as MSysAccessStorage.

In Access 2003 (I believe the OP is using Access 2003) when I try to
link to MSysAccessStorage in another db, the linked table is named
MSysAccessStorage1 by default. I haven't been able to rename it to
MSysAccessStorage.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200608/1

Aug 7 '06 #8
"rdemyan via AccessMonster.com" <u6836@uwewrote in
news:6463ce9f7f344@uwe:
This damned MSysAccessStorage table keeps getting linked to my front
end. I don't know why. It's the only system table that keeps getting
linked. I delete it and then my code seems to be relinking it but no
other system tables.
and your code is?

--
Lyle Fairfield
Aug 7 '06 #9
A couple of notes:
1) I use a global error handler
2) My backends have all permissions removed so I use RWOP queries in the
front end.
3) I'm a beginning/intermediate programmer, so be gentle :)

Okay, here it is

Public Function RelinkToCurDir(PassedBEFile As String, FullPathProvided As
Boolean) As Boolean
'Note, when all permissions have been removed from the backend tables
'and with RWOP, relinking will cause an error and the code must use Resume
'Next. This is by design from Microsoft. When the error is ignored,
'then the relinking will work.
'3/22/2006 NOTE: Must use On Error Resume Next at the top of the code.
Trapping
'the error in an error handler and then using Resume Next does not work.
'THIS IS EXTREMELY IMPORTANT

On Error GoTo Err_Ctrl

Dim wsBACK As DAO.Workspace
Dim dbBACK As DAO.Database
Dim BEFile As String

Dim stDocName As String
Dim db As Database
Dim tdf As TableDef
Dim X As Boolean, TableToLink As String
BEFile = PassedBEFile
'NOTE: 3/25/2006: dbBACK needs to be included. If only db is used, then all
links are included
'(about 150) and are deleted each time as each backend file is linked. By
using dbBACK, we
'get the count of the tables from the backend file.

Set wsBACK = DBEngine.Workspaces(0)
Set dbBACK = wsBACK.OpenDatabase(BEFile)
Set db = CurrentDb()

On Error Resume Next

'Now link the tables
For k = dbBACK.TableDefs.Count - 1 To 0 Step -1

TableToLink = dbBACK.TableDefs(k).Name

'Delete the link if it already exists.
'Using the .Connect statement assures that only linked
'tables get deleted and not any front end tables

If fIsRemoteTable(TableToLink) Then
db.TableDefs.Delete TableToLink

Else
'Don't delete any front-end tables
'and Don't delete links that don't exist

End If

'Create the new link
Set tdf = db.CreateTableDef(TableToLink)

'Set the properties of the new link
'and append to the tabledefs collection
tdf.SourceTableName = TableToLink
tdf.Connect = ";DATABASE=" & BEFile
db.TableDefs.Append tdf

Next k

RelinkToCurDir = True
Exit_Function: On Error Resume Next

Set db = Nothing
Set dbBACK = Nothing
Set tdf = Nothing

Exit Function
Err_Ctrl:

'This is the error where the backend can't be found. This will cause a loop
error if not
'trapped here that takes about 30 to 50 cancels to stop.
If Err.Number = 3024 Then
Resume Exit_Function
ElseIf Err.Number = 3078 Then
Resume Exit_Function
End If

DoCmd.Hourglass False
errMsgStr = ""
ctrlfnctnm = "RelinkToCurDir"
Call StartupModule_err(Err.Number, Err.DESCRIPTION, Err.Source,
ctrlfnctnm, errMsgStr)
Resume Exit_Function
End Function

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++

Function fIsRemoteTable(strTbl As String) As Boolean

'Checks if a table is a linked table or this database table

Dim wsLOCAL As DAO.Workspace, dbLOCAL As DAO.Database, rsLOCAL As DAO.
Recordset
Dim rsLOCALFlag As Boolean
Dim strSQLLOCAL As String

On Error GoTo Exit_Sub

strSQLLOCAL = "SELECT Name FROM MSysObjects WHERE Type = 6 AND Name = '" &
strTbl & "';"
Set wsLOCAL = DBEngine.Workspaces(0)
Set dbLOCAL = wsLOCAL.OpenDatabase(CurrentProject.FullName)
Set rsLOCAL = dbLOCAL.OpenRecordset(strSQLLOCAL, dbOpenDynaset, dbSeeChanges)
rsLOCALFlag = True

If rsLOCAL.RecordCount = 0 Then
'Local Table or doesn't exist in table
fIsRemoteTable = False
Else
'Remote table
fIsRemoteTable = True
End If

Exit_Sub: On Error Resume Next

If rsLOCALFlag = True Then
rsLOCAL.Close
Set rsLOCAL = Nothing
dbLOCAL.Close
Set dbLOCAL = Nothing
Set wsLOCAL = Nothing
rsLOCALFlag = False
End If
DoCmd.SetWarnings True
Exit Function

Err_Ctrl:

DoCmd.Hourglass False

If Err.Number = 3265 Then
fIsRemoteTable = False
Resume Exit_Sub
End If

errMsgStr = ""
ctrlfnctnm = "fIsRemoteTable"
Call StartupModule_err(Err.Number, Err.DESCRIPTION, Err.Source,
ctrlfnctnm, errMsgStr)
Resume Exit_Sub
End Function


Lyle Fairfield wrote:
>This damned MSysAccessStorage table keeps getting linked to my front
end. I don't know why. It's the only system table that keeps getting
linked. I delete it and then my code seems to be relinking it but no
other system tables.

and your code is?
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200608/1

Aug 7 '06 #10
3) I'm a beginning/intermediate programmer, so be gentle :)

OK.

1. Did you write this? This will have a bearing on the degree of
gentleness.

2. I know nothing of RWOP so someone who does will have to comment on
its impact on relinking.

3. Using On Error Resume Next to allow for a specific error will
conceal such other errors as exist.

4. You code starts in the BE to find the names of tables that should be
relinked. As I read it it will try to link the BE System Tables, but
should fail because a link to them will not be found in the FE. But
consider that in relation to # 3 above. Could the combination of the
two result in a link being made to a System Table in the BE? Well, it
seems that something does and for me Resume Next is the first thing
that jumps out at me.

5. IMO the simplest solution is that you discard this code and either
do a search for relinking code, or that you explain your situation
clearly here in CDMA and ask for suggestions.

Aug 7 '06 #11
Actually, the relinking code comes from Microsoft for linking tables where
all permissions are revoked (Security FAQ)

Yes, I hate the On Error Resume Next, but according to Microsoft Security FAQ,
it is the only way. As my notes state in the code I tried to use the error
handler but it failed. I've written a bunch of notes to remind myself of why
I did things, otherwise I forget and then waste time rewriting the code (that
I haven't looked at in months) and then ultimately have to go back to the
original.

Lyle Fairfield wrote:
>3) I'm a beginning/intermediate programmer, so be gentle :)

OK.

1. Did you write this? This will have a bearing on the degree of
gentleness.

2. I know nothing of RWOP so someone who does will have to comment on
its impact on relinking.

3. Using On Error Resume Next to allow for a specific error will
conceal such other errors as exist.

4. You code starts in the BE to find the names of tables that should be
relinked. As I read it it will try to link the BE System Tables, but
should fail because a link to them will not be found in the FE. But
consider that in relation to # 3 above. Could the combination of the
two result in a link being made to a System Table in the BE? Well, it
seems that something does and for me Resume Next is the first thing
that jumps out at me.

5. IMO the simplest solution is that you discard this code and either
do a search for relinking code, or that you explain your situation
clearly here in CDMA and ask for suggestions.
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200608/1

Aug 7 '06 #12
"rdemyan via AccessMonster.com" <u6836@uwewrote in
news:646565e6e0bb0@uwe:
Actually, the relinking code comes from Microsoft for linking tables
where all permissions are revoked (Security FAQ)
The article is not wonderfully clear; I am taking from what you say that
we must delete links and recreate them, ignoring errors, rather than
relink tables which are used by RWOP queries.

Surely someone can write simpler code than that (the code in the
article). IMO, Resume Next is not a great idea here unless it's a last
resort. Well even then it's not a great idea.

I hope there is someone reading this who uses RWOP and can create or
perhaps has already created code to relink tables used by RWOP queries.

How I would start is shown below. I am handicapped by not knowing the
error number which appears (which is why I'm munging by checking to see
if "permission" appears in the error description), and not having an
application with RWOP queries.

Just in case you decide to try this bear in mind, please,

a) it should be used only on a safe copy;
b) it's complete as it is but it must be called with the new backend path
as a parameter eg,
Sub test()
RelinkTables "C:\Documents and Settings\Lyle Fairfield\My Documents
\Access\northwind.mdb"
MsgBox "Done"
End Sub
;
c) I'm hoping it will motivate someone to post, "This is how it could be
done efficiently;
d) it may have a few undocumented methods (not sure, my code often does
but I haven't checked);
e) and that it will serve as a catalyst for the creation of a solution to
your System Table Link problem;
f) I've removed all indents to try to make it fit here but there may be
some lines split by the news clients and these will result in syntax
errors.

Sub RelinkTables(ByVal LinkTable As String)
Dim AttachedTables() As String
Dim CreateTableDef() As String
Dim Iterator As Long
Dim TableDefinition As dao.TableDef
Dim ThisDB As dao.Database
On Error GoTo ReLinkTablesErr
LinkTable = ";DATABASE=" & LinkTable
Set ThisDB = CurrentDb
AttachedTables = _
Split( _
CurrentProject.Connection.Execute( _
"SELECT Name, " _
& "ForeignName " _
& "FROM MSysObjects " _
& "WHERE Type = 6").GetString( _
adClipString, , ",", vbNewLine), vbNewLine)
With ThisDB
For Iterator = 0 To UBound(AttachedTables) - 1
CreateTableDef = Split(AttachedTables(Iterator), ",")
With .TableDefs
..Delete CreateTableDef(0)
..Refresh
Set TableDefinition = ThisDB.CreateTableDef(CreateTableDef(0))
With TableDefinition
..SourceTableName = CreateTableDef(1)
..Connect = LinkTable
End With
..Append TableDefinition
End With
Next Iterator
End With
ReLinkTablesExit:
Set ThisDB = Nothing
Exit Sub
ReLinkTablesErr:
With Err
Select Case .Number
Case 3021
MsgBox "No Linked Tables were found.", vbInformation, "Relinking Tables"
Resume ReLinkTablesExit
Case Else
If InStr(.Description, "Permission") <0 Then
Resume Next
Else
MsgBox .Description, vbInformation, "Relinking Tables Error # " & .Number
Resume ReLinkTablesExit
End If
End Select
End With
End Sub

--
Lyle Fairfield
Aug 7 '06 #13
"rdemyan via AccessMonster.com" <u6836@uwewrote in
news:646565e6e0bb0@uwe:
Actually, the relinking code comes from Microsoft for linking
tables where all permissions are revoked (Security FAQ)

Yes, I hate the On Error Resume Next, but according to Microsoft
Security FAQ, it is the only way. As my notes state in the code I
tried to use the error handler but it failed. I've written a
bunch of notes to remind myself of why I did things, otherwise I
forget and then waste time rewriting the code (that I haven't
looked at in months) and then ultimately have to go back to the
original.
Several points:

1. you can exclude system tables from any relinking by one of two
methods:

a. test the tabledef attributes for dbSystemObject (see the DAO
help for TableDefs.Attributes)

b. test if the table has a connect string -- if it does, it's an
attached table, if not, it's local.

2. don't use the tables in the back end as your source for what to
relink to. Simply use the existing linked tables in the front end.
That will prevent having to check the back end.

3. if the tables in the back end are available only to the owner,
then your users may be unable to relink. You may have to run your
relinking code in a separate workspace with a different user logon.

4. you might want to look at my relinking utility for databases with
multiple back ends:

http://www.dfenton.com/DFA/download/...Reconnect.html

It's not designed for use in apps with only one back end, but you
may find a look at the code useful in helping you understand how to
get the job done.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Aug 7 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael, | last post by:
I dont want to see these at all and cannot find where to specify a view or modification of a view. can someone throw me a bone here and tell me where to make the adjustments if I can make them...
4
by: Kevin Haugen | last post by:
SQL SERVER 2000 System let's you alter the system tables and add indexes. However, it won't let you drop the index afterward. Anybody know how to drop an index on a system table? Thanks, ...
2
by: T Chaudhary | last post by:
Hi, I want to replicate the system tables of the Northwind database in another test database that I have created (say NorthwindTest). I started with the syscomments table: insert into...
4
by: serge | last post by:
I tried all the INFORMATION_SCHEMA on SQL 2000 and I see that the system tables hold pretty much everything I am interested in: Objects names (columns, functions, stored procedures, ...) stored...
9
by: Vassago | last post by:
Hi! I need to recreate the system tables (sysobjects, syscolumns, sysindexes, sysforeignkeys, sysconstraints, sysreferences, sysindexkeys at least) in another SQL server. You may say "Thats easy!...
4
by: Boris Popov | last post by:
Hello pgsql-general, When trying to create a table CREATE TABLE sessions ( id serial PRIMARY KEY, procpid int4 REFERENCES pg_listener(listenerpid) ON DELETE CASCADE ); I get a warning...
1
by: pemigh | last post by:
I'm almost done with an application, and trying to lock it down tightly. But I still want users to be able to point to a new location for the data file. The code below fires off to detect and...
1
by: TGEAR | last post by:
I am using MS SQL Server management studio. I treid to see some system tables which are sysobjects, syscolumns, systypes, etc.., but i don't see the list under the system tables folder. There is...
8
by: Neil | last post by:
I just started using Access 2003, and I can't link a SQL Server table. I right-click on the database window; select Link Tables; and select ODBC Databases from the Files of Type dropdown. As soon...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.