acFormReadOnly Allows Edits bug. (1 Viewer)

Royce

Access Developer
Local time
Today, 17:24
Joined
Nov 8, 2012
Messages
99
This line is in the OnClick event of a subform. I want to open stDocName read only.
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormReadOnly, , strCaller

When the form opens Me.AllowAccess is false in both the Load event and the OnCurrent event. Yet I can edit all the data, close the form, and the edits show up in the calling form.

I've started with the decompile option, performed a Compact and Repair, and changed the database from Access 2003 to 2010. Still same problem. Access version 14.0.7106.4003 (32bit)

Anyone seen this before? Any suggestions on a solution?
 

JHB

Have been here a while
Local time
Tomorrow, 00:24
Joined
Jun 17, 2012
Messages
7,732
When the form opens Me.AllowAccess is false in both the Load event and the OnCurrent event.
What is "Me.AllowAccess, (a control on your form or ..)?
You do not have any code running in the form, which overrule the "acFormReadOnly"?
 

micks55

Registered User.
Local time
Today, 23:24
Joined
Mar 20, 2006
Messages
110
I think I might have overcome this with an extra line of code when opening the form ...
strDocName = "myFrm" 'usual stuff
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!myFrm!EditRO.Caption = "Read Only" 'label on the called form - tell user it's RO
Forms!myFrm.AllowEdits = False
 

Royce

Access Developer
Local time
Today, 17:24
Joined
Nov 8, 2012
Messages
99
Me.AllowAccess should have been Me.AllowEdits. I was brain dead by the time I posted the message.
 

Royce

Access Developer
Local time
Today, 17:24
Joined
Nov 8, 2012
Messages
99
I got it working. The OnCurrent Event was calling an AfterUpdate event that changed (edited) the value of a control. As the call to the code was not needed I commented out the one line and the form worked as expected. i.e. read only. Strange, as before and after the value of Me.AllowEdits was false.

I've always avoided calling an Event as a "not recommended practice." Create a Function, or sub, and call it instead. Years ago, (Access 95, 97 and before, I'm showing my age.) seems like there were a lot of these subtle bugs related to calling events directly.
 

missinglinq

AWF VIP
Local time
Today, 18:24
Joined
Jun 20, 2003
Messages
6,423
...The OnCurrent Event was calling an AfterUpdate event that changed (edited) the value of a control....

...Strange, as before and after the value of Me.AllowEdits was false...
One of Access' many quirks is that if AllowEdits is set to False, and you populate a Control using VBA Code, the AllowEdits Property is set to and remains at True until you leave that Record.

...I've always avoided calling an Event as a "not recommended practice." Create a Function, or sub, and call it instead. Years ago, (Access 95, 97 and before, I'm showing my age.) seems like there were a lot of these subtle bugs related to calling events directly...
Been doing this since 2000, and being in forced retirement, for the past 8 years, have spent 8+ hours a day on this and half a dozen other Access forums, and have never run across this before. The sentence

'Create a Function, or sub, and call it instead'

really makes no sense; when you 'call an event,' you are, in fact, actually Calling a Sub, and a sub is a sub.

I don't doubt that there may have been a problem with this in Access 95/97, as I'm told that they were buggier than the Great Dismal Swamp, even after service packs came out, but I've heard of no such problem from Version 2003 onward.

Glad you got it solved!

Linq ;0)>
 

Users who are viewing this thread

Top Bottom