By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
bloody 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
'\\MainComputerName\CashSheet\CashSheetData.mdb'")

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
tdf.RefreshLink
End If
tdf.Attributes = dbHiddenObject
Next tdf

dbs.Close

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."
Application.Quit
Else
MsgBox "There was apparently an error in trying to link
to the server data at " & vbCrLf & strPath & vbCrLf & "Error: " & Err &
" " & Err.Description

End If

Else

MsgBox "The database will close now."
Application.Quit

End If

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

End Function

Oct 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"pemigh" <pe****@gmail.comwrote in
news:11**********************@f16g2000cwb.googlegr oups.com:
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
bloody 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.
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 http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Oct 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.