Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form allows edits when AllowEdit set to false (Access 2003)

Status
Not open for further replies.

BSman

Programmer
Apr 16, 2002
718
US
I have a form which can be in three states: AllowEdits false or true while AllowAdditions is false, or the third state of AllowAdditions is true.

There is a button on the form which enables the user to change the state of the form from AllowEdits false to AllowEdits true and back. The label on the button changes back and forth from Allow Edits to View Data.

The form opens in the allow additions mode and this button's label starts as "View Data". When clicked, after checking if the user wants to save the new record, the form is set to the AllowEdits false state and the background color changes from green (add mode) to grey (view mode). The button now says "Allow Edits" and, when clicked, the color changes to yellow and AllowEdits state changes to true. So far, so good. However, when the user clicks the button again, AllowEdits is set to false (I confirmed this with various test messages) and the background changes to grey. The background color of grey or yellow is set based on the status of AllowEdits. There is only one place in the code where AllowEdits is set to true.

However, when the user returns to the view data state, the header data on the form can still be changed. I've tested everything I can think of and can't find anyplace in the code (or elsewhere) that would allow editing the data even while the form is set to AllowEdits as false. And the form status is changed correctly the first time, but not after.

Is this an Access quirk or is there something else I need to look at?

Bob
 
Hi BSman,
I think that as long the allow additions is set to true, it will allow edits too.
it looks like your form is opening with allow additions set true, and it stays all the time true (the button changes only the allow edit). Is that right?
Ja
 
Hi Ja,

Actually, the first time the user clicks on the view button, the form goes to the allow edits false mode. Then it goes to allow edit true when the user clicks the button; however, if the user again clicks the button (which at this point says "View data"), even though allow edits is set to false (and the form background changes to the color indicating it is in the view only mode), you can still make changes.

However, I figured out the solution to the problem. When the user clicks the "View data" button to go into the view mode, after setting AllowEdits to false, I added the following line of code:

me.Refresh

That solved the problem. After exhausting all other ideas I could think of, I finally thought of the refresh action (which I seldom need to use), and it solved the problem. Apparently, the form does not recognize any changes to it's allow edits status after the status has been changed once or twice.

Bob
 
Hello Bob, Thanks for posting your solution. djj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top