UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Hide Dao.querydef, Access 2013    
 
   
gint32
post Feb 12 2019, 06:39 PM
Post#1



Posts: 368
Joined: 8-May 09
From: Australia


I am attempting to hide all my DAO.TableDef and querydef from users, but so far the only thing I can hide is the tables, I don't seem to see a Attributes property for the Qry_Def.Attributes with using the below VBA, can anyone throw some light on the the subject as to where I'm going wrong? As for me at this point am stuck.

Also, what I'd really like to do is hide all forms, tables, queries and macros from users.

CODE
Public Sub VisualAttribs()

' Reset all the applications forms to hidden

        Dim db As DAO.Database
        Dim tdf As DAO.TableDef
        Dim Qry_Def As DAO.QueryDef

        
        Set db = CurrentDb

        'Loop through the TableDefs Collection.
        

        Application.SetOption "Show Table Names", 0  
        DoCmd.ShowToolbar "Ribbon", acToolbarNo
        
        DoCmd.LockNavigationPane True
        
                For Each tdf In db.TableDefs
                
                            tdf.Attributes = acHidden 'Hide Tables
                            'Qry_Def.Attributes = acHidden ' Hide QueryDef
                Next tdf
            
            
               For Each Qry_Def In db.QueryDefs
                
                            Qry_Def.Attributes = acHidden 'Hide Tables
                            
                Next Qry_Def
            
          
End Sub
Go to the top of the page
 
ADezii
post Feb 12 2019, 06:56 PM
Post#2



Posts: 2,368
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. Unlike TableDefs, a QueryDefs does not have an Attributes Property, but you can hide all Queries programmatically:
    CODE
    On Error Resume Next
    Dim qdf As DAO.QueryDef

    For Each qdf In CurrentDb.QueryDefs
      SetHiddenAttribute acQuery, qdf.Name, True
    Next
  2. You can check and see if the QueryDef is initially hidden via:
    CODE
    If Not qdf.GetHiddenAttribute (acQuery, qdf.Name) Then        'Query is NOT HIdden
      'Hide it
    End If

This post has been edited by ADezii: Feb 12 2019, 07:00 PM
Go to the top of the page
 
gint32
post Feb 12 2019, 07:14 PM
Post#3



Posts: 368
Joined: 8-May 09
From: Australia


QUOTE
Unlike TableDefs

Thanks for that..

Is there also a similar way for Forms.
Go to the top of the page
 
isladogs
post Feb 12 2019, 07:52 PM
Post#4


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


Note that the code supplied from hiding queries is not equivalent to that for hiding tables.

Hidden queries can easily be made visible by ticking Show Hidden Objects in Navigation Options
That isn't true for tables hidden using acHidden attribute

Similarly forms/reports/modules can all be hidden but are easy to restore again

I would suggest that a better approach is to remove the navigation pane completely & then lock down Access options so users cannot restore it again

--------------------
Go to the top of the page
 
ADezii
post Feb 13 2019, 08:34 AM
Post#5



Posts: 2,368
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
Is there also a similar way for Forms.

Yes, the following Code will Hide all Open Forms that are Visible AND have a Tag Property = 'HideMe':
CODE
Dim frm As Access.Form

For Each frm In Forms
  With frm
    If .Visible And .Tag = "HideMe" Then
      .Visible = False
    End If
  End With
Next

P.S. - This Code is for Reference only, isladog's approach is a sound one and a better option.
This post has been edited by ADezii: Feb 13 2019, 08:35 AM
Go to the top of the page
 
isladogs
post Feb 13 2019, 08:52 AM
Post#6


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


Can I also just point out that applying tdf.Attributes = acHidden code to all tables as you have will also affect system tables
Whilst it is possible to undo the acHidden attribute for tables (if you know how.... and I'm deliberately not saying how), doing so will convert all those system tables back to normal tables.
They would then be visible by default in the nav pane - not a good idea.

That's why I recommended an alternative approach of removing the nav pane etc.
Personally I wouldn't apply acHidden to the tables as it will prevent all access to those tables (unless you reverse the attribute)

--------------------
Go to the top of the page
 
River59
post Feb 13 2019, 09:16 AM
Post#7



Posts: 1,734
Joined: 7-April 10
From: Detroit, MI


I am wondering why you don't just create an .accde database for the users. That will hide everything?

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
isladogs
post Feb 13 2019, 10:50 AM
Post#8


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


ACCDE will hide the code and prevent any design changes to forms and reports but it won't prevent users directly editing tables and queries

--------------------
Go to the top of the page
 
gint32
post Feb 14 2019, 07:01 AM
Post#9



Posts: 368
Joined: 8-May 09
From: Australia


re-won't prevent users directly editing tables and queries
-----------------



yep, thats correct...tables are important to hide as nothing will be recorded when edited and existing queries well you can do the same if the users run them...!!!
Go to the top of the page
 
River59
post Feb 14 2019, 11:33 AM
Post#10



Posts: 1,734
Joined: 7-April 10
From: Detroit, MI


What am I missing with this question? When I distribute to the users, I go to File/Optiions/CurrentDatabase and turn off the navigation pane. Then, on Open Event of the main form, I put the code: DoCmd.ShowToolbar "Ribbon", acToolbarNo

Now when the user opens the database, all they see are the forms. No tables, no queries, no forms, no reports, no macros, etc. You take them only to where you want them to go.
This does not involve creating an accde.

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
isladogs
post Feb 14 2019, 01:22 PM
Post#11


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


@River59
QUOTE
What am I missing with this question?

For a start you are missing the fact that some of your suggestions have already been mentioned

From post #8
QUOTE
I am wondering why you don't just create an .accde database for the users. That will hide everything?

Incorrect.

In post #10 you suggest removing the navigation pane & ribbon and ensuring all navigation is done via forms.
I would agree with doing both of those and mentioned the navigation pane twice in posts #4 & #6 as part of a series of security measures

QUOTE
...This does not involve creating an accde.

Its still always wise to distribute files as ACCDE as another part of making apps as secure as possible

BUT doing all of those still does not make your database absolutely secure.
What measures do you have in place to prevent users undoing your security?
In fact have you ever had anyone test how secure your apps really are?

This is a quote from one of my web articles on Access security
QUOTE
Access databases can NEVER be made 100% secure
A capable and determined hacker can break any Access database given sufficient time and motivation.
However, by erecting various barriers, it is certainly possible to make the process so difficult and time consuming that it isn't normally worth attempting.



--------------------
Go to the top of the page
 
gint32
post Feb 14 2019, 05:02 PM
Post#12



Posts: 368
Joined: 8-May 09
From: Australia


QUOTE
This is a quote from one of my web articles on Access security


even after implementing most of that you can still query all tables from applications like MS Excel...
Go to the top of the page
 
isladogs
post Feb 14 2019, 05:34 PM
Post#13


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


Perfectly true. Or from another Access database
But you did say 'doing most of that ....'
If its that important, why not implement all security measures?

Remember that the strength of your security is just that of the weakest part of it
You can set up all sorts of security features but if you leave one part exposed.

Why don't you have a look at my security challenges & see if you can break into those?
See http://www.mendipdatasystems.co.UK/securit...nges/4594398127
The first one is relatively easy .... as I left an unintentional 'loophole'
The others are a lot harder

You could also look at the attached file - it has an FE that references a deep hidden table in a BE but with no linked tables so no connection strings available!
However the FE form can see the data in the usual way
The zip file explains how it works
In this example, I've supplied the BE password but you won't see the table in the nav pane even though its not been hidden



Attached File(s)
Attached File  LinkedNoTablesDEMO.zip ( 463.76K )Number of downloads: 16
 

--------------------
Go to the top of the page
 
gint32
post Feb 15 2019, 04:57 PM
Post#14



Posts: 368
Joined: 8-May 09
From: Australia


QUOTE
Why don't you have a look at my security challenges & see if you can break into those?


Thanks, I have had a look, but I found them way to complicated for my little brain to process. Wish I had more time to play with Access though as the more you learn the more interesting it gets.
Go to the top of the page
 
isladogs
post Feb 15 2019, 05:18 PM
Post#15


UtterAccess VIP
Posts: 1,413
Joined: 4-June 18
From: Somerset, UK


Also the more I learn....the more I realise I don't know!

Did you look at the LinkedNoTables DEMO as you can see all the code to work out how its done

--------------------
Go to the top of the page
 
gint32
post Feb 15 2019, 05:34 PM
Post#16



Posts: 368
Joined: 8-May 09
From: Australia


I downloaded, had a quick browse but not had a proper look as yet, but I will when I am not so tired (got the big C) and have the time(6:30AM here)...many thanks for your help!
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    16th June 2019 - 09:43 AM