Allen (or anyone else who can help),
I've tried to use the method you outline below with no success.
I have a form with a button to toggle back and forth between "Edit" mode
and
"Read-Only" mode (the button calls a macro that sets the AllowEdits,
AllowDeletions and AllowAdditions properties). The button works great,
but
now I have some code that I only want to fire if the form is in "Edit"
mode.
I tried using "If Forms("frmExample").AllowEdits Then" but it aways
evaluates to True and executes the statements after Then. I also tried
"If
Forms("frmExample").AllowEdits = True Then" and got the same results. I
then
tried printing to the Immediate window (Debug.Print Forms![Purchase
Order]![Ship History subform].AllowEdits) and got a carriage return.
Thinking a Null might be the problem I used the Nz function and got the
same
result (a carriage return).
I've tried every combination of the above I could think of and tested each
for both AllowEdits = True and AllowEdits = False. What am I doing
wrong???
I actually have a workaround for this situation, but I'd like to know
what's
going wrong; there are other times when I'd like to be able to determine
whether the form is in "Edit" mode or not.
Thaks for all your help.
Kari
Allen Browne said:
Not sure how you define "read-only", but you could test the AllowEdits
property of the form:
If Forms("frmExample").AllowEdits Then
MsgBox "read only"
Else
MsgBox "normal
End If
That should work if the form was opened this way:
DoCmd.OpenForm "frmExample",,,,acFormReadOnly
However, there are many other reasons a form might be read-only, such as:
- It is based on a query that is not updatable.
- The user does not have write privileges.
- The database was opened read-only, or the drive or media is read-only.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
How do I determine if a form has been opened in read ony mode.
ie. If frmExample "Is opened as read only" then
do whatever
Else
do something else
End if
TIA,
Duncan