Hiding Design View from users

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dileshw
    New Member
    • Oct 2009
    • 21

    Hiding Design View from users

    Hi,
    I am making a database amd i dont want users seeing the stuff thats happening in the background. So i would like to hide everything so that ONLY I can see it. Doing some reading online (and asking friends) I learnt of a few things i can do:

    1- right now i have hidden the design view using tools->startup (and unchecking all boxes). But if someone knows a bit of access they can get into the design view by using SHIFT+open. I read online that you can disable the SHIFT-overide. Sadly the code i found for the same didnt work. Can someone tell me how I can do this?

    2- Create an application out of the DB so that its not modifuable (structure-wise). I have not seen this done, and its pure hear-say.

    Can someone help me out on this please. Thanks!
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32668

    #2
    Both use the Tools menu.
    1. Startup...
      This enables you to control use of Access Special Keys (of which Shift at startup is one).
    2. Database Utilities...
      This gives an option to create MDE file. This works up to version 2003. I expect something similar is available in later releases.

    Comment

    • munkee
      Contributor
      • Feb 2010
      • 374

      #3
      @dileshw

      I use the following code which I found a few months ago now (I honestly can't remember where I found it but thank you to the writer) to stop users getting access via holding down SHIFT as the database loads:

      Place the following in a module:

      Code:
      Option Compare Database
      Option Explicit
      
      Public Function SetProperties(strPropName As String, _
      varPropType As Variant, varPropValue As Variant) As Integer
      
          On Error GoTo Err_SetProperties
      
          Dim db As DAO.Database, prp As DAO.Property
      
          Set db = CurrentDb
          db.Properties(strPropName) = varPropValue
          SetProperties = True
          Set db = Nothing
      
      Exit_SetProperties:
          Exit Function
      
      Err_SetProperties:
          If Err = 3270 Then    'Property not found
              Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
              db.Properties.Append prp
              Resume Next
          Else
              SetProperties = False
              MsgBox "SetProperties", Err.Number, Err.Description
              Resume Exit_SetProperties
          End If
      End Function
      Create a form which loads on startup or use an existing form which you have that loads on startup, for me this is usually the user login form on my custom system.

      Place a button on the form with the following code behind it:

      Code:
      Private Sub btnbypass_Click()
       On Error GoTo Err_bDisableBypassKey_Click
          'This ensures the user is the programmer needing to disable the Bypass Key
          Dim strInput As String
          Dim strMsg As String
          Beep
          strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
                   "Please key the programmer's password to enable the Bypass Key."
          strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
          If strInput = "[B][I]PASSWORDHERE[/I][/B]" Then
              SetProperties "AllowBypassKey", dbBoolean, True
              Beep
              MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
                     "The Shift key will allow the users to bypass the startup options the next time the database is opened.", _
                     vbInformation, "Set Startup Properties"
          Else
              Beep
              SetProperties "AllowBypassKey", dbBoolean, False
              MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
                     "The Bypass Key was disabled." & vbCrLf & vbLf & _
                     "The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", _
                     vbCritical, "Invalid Password"
              Exit Sub
          End If
      Exit_bDisableBypassKey_Click:
          Exit Sub
      Err_bDisableBypassKey_Click:
          MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
          Resume Exit_bDisableBypassKey_Click
      End Sub

      Where I have use the bold/italics type in a password. This will be used to enable/disable the shift key if you wish to be able to use it during your testing.

      Now go back to your form and set the button to transparent. This way when the form loads only you will know where it is. When you click the area it will load up a dialog for you to enter the password you created above. This will then disable the shift key.

      The shift key will remain disabled for the file until you put the password back in to enable it.

      Any questions let me know.

      Comment

      • patjones
        Recognized Expert Contributor
        • Jun 2007
        • 931

        #4
        If you are using Access 2007, go to the Database Tools tab and note the "Make ACCDE" option. This will produce a locked copy of the database for you, although you might still need to follow the advice of others here in order to disable the SHIFT button on start-up.

        Pat

        Comment

        • dileshw
          New Member
          • Oct 2009
          • 21

          #5
          I tried the acode above..But i get a runtime-error (3270)...
          aparentlythe bug is in this this line.
          Code:
              db.Properties(strPropName) = varPropValue

          Comment

          • patjones
            Recognized Expert Contributor
            • Jun 2007
            • 931

            #6
            I tried the code out and it works fine for me. Maybe you could try creating the property before using it. First do this:

            Code:
            Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
            db.Properties.Append prp

            Then do this:

            Code:
            Set db = CurrentDb
            db.Properties(strPropName) = varPropValue
            SetProperties = True
            Set db = Nothing

            If that fails, perhaps you can post the code as you have it just in case you made an error in pasting it into your VBA module

            Pat

            Comment

            • patrick khattar
              New Member
              • Nov 2010
              • 2

              #7
              Hi Pat

              Is there any way to set the strInput Input Mask of the msg box to be password??

              Comment

              • patjones
                Recognized Expert Contributor
                • Jun 2007
                • 931

                #8
                Hi Patrick,

                If you are referring to setting the input mask for an input box to be a password mask, yes it appears to be possible. I found one way to do this on another forum, which you can see here. This process involves some Windows system calls and might be more trouble than it's worth.

                The simpler route would be for you to create a small modal form with a text box, and set the text box input mask to "Password". It will add very little code to your project and probably be just as quick as implementing the input box solution.

                Pat

                Comment

                Working...