I have an Access Database in Access 2007 and I’m trying to set read-only access permissions using subroutines. I have this subroutine in each Form I want locked
Sub Form_Open(Cancel As Integer)
SetAccess (Form_Routes)
End Sub
and this Public Sub that I want to control the actual form properties.
Public Sub SetAccess(oForm As Object)
With oForm
.AllowAdditions = EditAccess
.AllowDeletions = EditAccess
.AllowEdits = EditAccess
End With
End Sub
EditAccess is a boolean value that the user can toggle to prevent accidental edits.
I want to use a single subroutine so if I want to change how the access permissions work, I can change it in one place rather than each form that should get locked as I have almost a dozen forms.
When I Open the form Form_Routes, it returns the error
“Run-time Error ‘438’: Object doesn’t support this property or method”
I tested whether it was the form name Form_Routes by replacing oForm with Form_Routes and it works fine but I think I need to pass the form name as an Object variable for this to work the way I envision.
What I want to happen is when the form opens, it checks whether the user has turned on editing and set the appropriate properties.
Chandler Motley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.