in message:
i'm opening a form from a command button on another form and depending on
certain criteria the form can be opened read only using the data mode
argument under the OpenForm method - all works fine.
However, later on in my code i want to test to see if the form is opened as
read only or not and i can't seem to find a way to do this ... any ideas?
Hi Julie,
You can test the form's various settings for AllowEdits, AllowDeletions,
and AllowAdditions. Here is some generic code as an example which
you can hopefully incorporate into your code. This assumes you want
to test the properties of the *other* form. If you want to test the form
running the code you can just use Me.Form.AllowAdditions, etc.
'*********Start of sample code*************
Private Sub cmdShowDetails_Click()
On Error GoTo ErrorPoint
Dim frm As Form
DoCmd.OpenForm "frmDetails", , , , acFormReadOnly
Set frm = Forms!frmDetails
If frm.AllowEdits = False And frm.AllowDeletions = False _
And frm.AllowAdditions = False Then
' Form is read-only, do what you wish
MsgBox "Form is read-only"
Else
' Form is not completely read-only, do something else
MsgBox "Form is not read-only"
End If
ExitPoint:
' Cleanup code
Set frm = Nothing
Exit Sub
ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint
End Sub
'*********End of sample code*************
You might want to test to make sure the form is actually opened too.
Hope that helps,