Trying to re-link hidden tables and keep them hidden - but not TOO hidden!

Trying to re-link hidden tables and keep them hidden - but not TOO hidden!

Post by pemig » Sun, 22 Oct 2006 04:25:16

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 address the problem of a
moved/renamed data file. The problem: WITHOUT the "tdf.Attributes =
dbHiddenObject" line, my previously hidden tables are now visible.
(Not that the users will normally have the chance to see them, hidden
or not.)

WITH the "tdf.Attributes = dbHiddenObject" code, the tables are
*** y well hidden! Can't see them even if "show hidden objects"
is on.

Any ideas? If so, please be specific about how to deal with
Attributes. They are still a bit mysterious to me.

P. Emigh


Public Function fOpenMain()

Dim dbs As Database
Dim tdf As TableDef
Dim strPath As String

On Error Resume Next

DoCmd.OpenForm "fmnuSwitchboard"

If Err = 3043 Or Err = 3024 Or Err = 3044 Then
If MsgBox("Data file note found, likely because it was moved or
renamed. Would you like to re-link data?" & vbCrLf & vbCrLf & "CAUTION:
Failing to do this correctly could cause data corruption!" & vbCrLf &
vbCrLf & "If you choose NO, you'll have another chance to link to the
data file next time you open the database.", vbYesNo) = vbYes Then

Err = 0

strPath = InputBox("Path and name of data file:" & vbCrLf &
vbCrLf & "Your response might look something like

Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
' Re-set links to all the linked tables
If tdf.connect <> "" Then
tdf.connect = ";DATABASE=" & strPath
End If
tdf.Attributes = dbHiddenObject
Next tdf


If Err = 0 Then
MsgBox "Links created successfully. The database will
close now. Re-open it, and then you should be able to proceed with
your work."
MsgBox "There was apparently an error in trying to link
to the server data at " & vbCrLf & strPath & vbCrLf & "Error: " & Err &
" " & Err.Description

End If


MsgBox "The database will close now."

End If

End If

If Err <> 0 Then
MsgBox Err & " " & Err.Description
DoCmd.OpenForm "fpopPW"
End If

End Function

Trying to re-link hidden tables and keep them hidden - but not TOO hidden!

Post by David W. F » Sun, 22 Oct 2006 08:00:08

"pemigh" < XXXX@XXXXX.COM > wrote in

What do you want? Hidden tables that don't show up to anyone or
hidden tables that don't show up if you have the options set to show
hidden objects?

I don't see why you're worrying about it. I've never hidden tables,
ever -- can't see the point. If the users shouldn't be able to see
them, then, they should be locked out of the database window.

Also keep in mind that hidden tables are not shown in the list of
tables in the QBE if you have SHOW HIDDEN OBJECTS turned off, so
that would be a pain to users who are editing queries (though if
you've got the db window hidden, they are unlikely to do that,
unless you're opening queries for them in design view).

So, basically, I don't know what your question is, nor can I offer
an answer, since it's not clear to me that there is any real value
in what you seem to be attempting.

The HIDDEN status should remain the same for existing table links
when the connect string is updated, that is, the property that you
see with the properties sheet of the table, and that is related to
the OPTION for showing hidden objects.

David W. Fenton
usenet at dfenton dot com