Can I set table.visible = false

sambo

Registered User.
Local time
Today, 08:33
Joined
Aug 29, 2002
Messages
289
I have established whether or not a user is an admin based on the login form and table i created. Now i need to let admin view and design tables, and allow all other users only to use forms.

Something like this:

If Admin = True Then
AllTables.Visible = True
AllTables.Designable = True
Else
AllTables.Visible = False
AllTables.Designable = False
End If

Can I do something similar to this. I'm trying to make a very quick fix to keep stupid users from deleting data in the tables.

Ps.. I do not want to use groups or security wizard or anything that in depth. Not worth all the hassle.
 
The fastest fix is to just make sure all the tables and queries are hidden and that your users don't have the Tools->Options->View->Show->Hidden Objects checkbox checked.

I'm thinking there might be a way to set this option via VBA but couldn't tell you what it is off the top of my head (and maybe not even with a little research).

Peace
 
yes,
That is one way, but how can i make sure that all of the users have this box unchecked. If there are constantly more users coming online, then I will need to automatically set the check box to unchecked. I need to know how to do this based on code.
 
Try this.

Application.SetOption "Show Hidden Objects", False
 
How do i use this command:
acCmdHideTable

I tried this:
DoCmd.RunCommand acCmdHideTable "myTable"

That didn't work, what is the proper syntax?
 
Got what i was looking for:

Application.SetHiddenAttribute acTable, "tblUnits", True

Thanks
 
Alright, I've spent the better part of the day tinkering with this routing and I'm finally finished, so I figured I should show it to anyone who may need such a thing.

Function setHidden(objType As Integer, hideIt As Boolean)
'setHidden(int,bool) sets the hidden properties of Applicaiton objects ie tables, queries, forms
'objType determines table, query or form
'hideIt hides or shows objects dependent on true of false

Dim myObj As AccessObject, fromWhat, db As Object, whatType As Integer
Set db = Application.CurrentData
Select Case objType
Case 1
Set fromWhat = db.AllTables
whatType = 0 'acTable int val = 0
Case 2
Set fromWhat = db.AllQueries
whatType = 1 'acQuery int val = 1
End Select
For Each myObj In fromWhat
On Error Resume Next
Application.SetHiddenAttribute whatType, myObj.Name, hideIt
Next myObj
End Function

Have Fun
 
Thanks for the function. Works great! But not for A97 since the SetHiddenAttribute is not available.
 
Be careful with the hidden attribute. I think that if you compact your db while the table is hidden, it will be deleted.
 
Thanks for the warning pat,
In order to combat this possible problem, I set hidden equal to false whenever Admin logs in, and hidden equal to true whenever other users log in.
This way the only person that would be compacting the DB (Admin) will always have the tables and queries visible. Do you think this is good enough safety net, or should I develop it some more.
 
I would try compacting the db with the tables hidden to see if they are really deleted. You might not need to worry about it.. The post that mentioned this problem was some time ago so I'm a bit fuzzy on the details. You could try searching for it.
 

Users who are viewing this thread

Back
Top Bottom