Forms can be opened in a "read only state" in VBA and by design:
Open your form in design mode
Show the property sheet
IN the property sheet drop down list, select "Form"
Data tab
At the bottom are four "Allow" properties
When I am creating a review only form, I set
allow Additions, Deletions, and Edits to No.
HOWEVER,
When using a cascading combobox for a form filter, Allow Edits has to be set to yes and using VBA to open the form as a readonly state can cause issues; therefor, in this case, I use the form's before_update event to cancel the edit.
Once again, show the form's property sheet
Event tab
Before Update
click on the [...]
Code Builder
You will get a blank
Form_BeforeUpdate(Cancel as Integer)
procedure, set cancel to true and tell the form to undo any edits.
A very simple version of this is
- Option Compare Database 'do not duplicate
-
Option Explicit 'do not duplicate
-
-
Private Sub Form_BeforeUpdate(Cancel As Integer)
-
Cancel = True
-
Me.Undo
-
End Sub
I have code the tells the user that edits are not allowed and/or opens a new/edit-record form