How to Disable Properties : MS Access

How to Disable Properties

We need to have the three VBA functions entered in the Module of Access. The completed VBA codes are listed below. We need to call the EnableProperties() function somewhere in the form with password protection. Then we will call the DisableProperties() function when program is opened.

 1)    Call EnableProperties() function under the Double Click button of the title My Code Collection in the Navigation form in order to allow the developer to update the VBA or program design.

enable

 

 

 

 

 

 

 

Private Sub Auto_Header0_DblClick(Cancel As Integer)
Dim strPasswd As String
   Dim counter As Integer
   Dim Remaining As Integer
   counter = 0
   Do Until counter = 3
   strPasswd = InputBox("Please Enter Password", "Password Required")
   'If a correct password is entered, then enable all properties
   'If incorrect password or no password entered then shows a message
   'for 3 times to re-enter a password
       If strPasswd = "5555" Then
           Call EnableProperties
           Exit Sub
       Else
           counter = counter + 1
           Remaining = 3 - counter
           MsgBox "Incorrect password!" & vbCrLf & _
                   "You have " & Remaining & " attempt(s) remaining!", _
                   vbOKOnly, "Password Info"
       End If
       Loop
End Sub

 2)   Call DisableProperties() under the On Load Event Procedure of the Navigation Form or Main Form that first loaded when open program.

Attention: before you call DiableProperties() function, make sure you have a backup file.

onLoadloadcode

 

 

 

 

 

 

 

 

 

 

Note: The Access program must be closed and reopened one to two times to make the property reset effective.

Put these three functions in the Module of Access
1) Function SetProperties()
Public Function SetProperties(PropName As String, PropType As Variant, PropValue As Variant) As Integer
On Error GoTo Err_SetProperties
   Dim db As Database, prop As Property
   'Dim db As DAO.Database, prop As DAO.Property (use in the old version prior 2007)
   Set db = CurrentDb
   db.Properties(PropName) = PropValue
   SetProperties = True
   Set db = Nothing
Exit_SetProperties:
Exit Function
Err_SetProperties:
   If Err = 3270 Then 'case of property not found
       Set prop = db.CreateProperty(PropName, PropType, PropValue)
       db.Properties.Append prop
       Resume Next
   Else
       SetProperties = False
       MsgBox "Runtime Error # " & Err.number & vbCrLf & vbLf & Err.Description
       Resume Exit_SetProperties
   End If
End Function

‘*************************************

2) Function DisableProperties()
Public Function DisableProperties()
On Error GoTo TheError
DoCmd.ShowToolbar "Ribbon", acToolbarNo
‘Disable properties listed below by setting the property value to False
SetProperties "StartUpShowDBWindow", dbBoolean, False
SetProperties "StartUpShowStatusBar", dbBoolean, False
SetProperties "AllowFullMenus", dbBoolean, False
SetProperties "AllowSpecialKeys", dbBoolean, False
SetProperties "AllowBypassKey", dbBoolean, False
SetProperties "AllowShortcutMenus", dbBoolean, False
SetProperties "AllowToolbarChanges", dbBoolean, False
SetProperties "AllowBreakIntoCode", dbBoolean, False
Exit Function
TheError:
MsgBox Err.Description
Exit Function
End Function
‘************************************
affiliate_link
3) Function EnableProperties()
Public Function EnableProperties()
On Error GoTo ErrorHandler:
DoCmd.ShowToolbar "Ribbon", acToolbarYes
‘Set all properties listed below back to normal by setting value to True
'Show Database window
SetProperties "StartUpShowDBWindow", dbBoolean, True
SetProperties "StartUpShowStatusBar", dbBoolean, True
'show Access Full Menus.
SetProperties "AllowFullMenus", dbBoolean, True
'enable F11, ALT F11, etc. for short key
SetProperties "AllowSpecialKeys", dbBoolean, True
'Shift Key Override on loading
SetProperties "AllowBypassKey", dbBoolean, True
'allow Access Shortcut Menus. May be too severe
SetProperties "AllowShortcutMenus", dbBoolean, True
SetProperties "AllowToolbarChanges", dbBoolean, True
SetProperties "AllowBreakIntoCode", dbBoolean, True
Exit Function
ErrorHandler:
MsgBox Err.Description
Exit Function
End Function

************************************************

 How to Enable Properties or Call Properties back
  1. Double Click on the My Code Collection title text on the Navigation form
  2. Enter password “5555” and click OK
  3. Exit program
  4. Open program again
  5. Right hand on form and click on Design View
  6. Open the On Load Event procedure
  7. Disable the DisableProperties() function on the Private Sub Form_Load() like

                     Private Sub Form_Load()

                            ‘ Call DisableSetProperty

                     End Sub

  1. Save VB and exit program
  2. Open program again and again until all or your properties come for you to able to update your program.

The matter is directly associated viagra online dechechland with the time management of the applicants. There are so many men these days who have become a fashion viagra samples accessory with more and more people choosing to buy henna based products due to their chemical-free nature. You will have the chance to* Have an erection have an erection that can last for several hours* You shall not worry about premature ejaculation* You have the problem of erectile dysfunction, you have to visit to a physician. cialis in usa It may not work at all the spamming that goes on with shady sites selling cialis professional cheap and Vicodin directly to the unsuspecting public, it is important that you go through the right channels so that there is no illicit activities being promoted in cyberspace and in the real world where drug laws actually prohibit that kind of sale to people.

Related posts

6 Thoughts to “How to Disable Properties : MS Access”

  1. andigirlsc

    I set up all three functions in my VBA code: SetProperties(), DisableProperties() and EnableProperties() as described above and called DisableProperties() if the user’s ID met a certain condition. This part works. I also called EnableProperties() if the user’s ID met a different condition. This part does not work. Once Access has disabled the properties in the function, it doesn’t seem to want to enable them again. I also made a copy of my database so that if I got locked out I could still resume work, which as it turns out was completely necessary. How do I get EnableProperties() to work properly?

    1. TGoldenEye

      after set click enable properties then close program and open it again. This time you will see the tabel or form list. right hand click on the opened forms and go to design view to disable the DisableProperties function like ‘Call DisableProperties(). Then close program and re-open program. EnableProperties will only give me one time chance to go in and disable the DisableProperties function. If you open program 2nd time without disable the DisableProperties function it will lock again.

  2. Tawfiq elBastaki

    Hi,

    This is a very useful code but it disables all ribbons including some vital functions. Is there any way this code can be modified so that it selectively enable the “Print Ribbon” when the user wants to print a report or a form?

    Thank you.

    Note: I am only an amateur programmer.

    1. TGoldenEye

      put these code on your report(every single one):
      Private Sub Report_Close()
      DoCmd.ShowToolbar “Ribbon”, acToolbarNo
      End Sub

      Private Sub Report_Load()
      DoCmd.ShowToolbar “Ribbon”, acToolbarYes
      End Sub

  3. B McNeill

    Can the disable/enable function be used for design and layout view?

    1. TGoldenEye

      yes, that’s what it for. for security purpose for user.

Comments are closed.