Odd behaviour with 'AllowEdit' property

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

Hello everybody,
This is odd!...but perhaps you might be able to offer an
explanation. I'll try and be brief.
FormLoad event sets the 'AllowEdits'property to NO.
I've put a command button on the form that, when clicked,
alters the property to YES so that the user may amend the
current record.
I've set the AfterUpdate event of the form to reset the
property to NO so that (hopefully!) when the user moves
to another record and/or clicks on Save, the records are
once again un-editable.
This works fine except for the following cases:
There's an OptionGroup within the form with two choices -
1 is the default.
If I allow Edits (by clicking on the command button) and
select option 2, I can continue to amend the record no
matter what I do. I can even close the app down! I
can't amend other records but I can amend any set to
option 2. I can't imagine what's going on here!
Any ideas would be very welcome.

Thanks in advance,

Lee
 
Lee,

I don't know what the issue is. Maybe the code in the option group would
give someone here a clue, but why not try setting the AllowEdit propery to
No in the current event of the form rather than the AfterUpdate and see if
that corrects the problem.

God Bless,

Mark A. Sam
 
Thanks for the quick response Mark and for the suggestion.

I've just tried it and I'm afraid this doesn't
help....doh!!

Regards,

Lee
 
Why not just use the form's BeforeUpdate event to decide whether to accept
or reject any edits, based on a value that you write into an invisible
textbox on the form? Put a textbox on the form (name it txtEdits) and make
it invisible. In the OnLoad event of the form, set it to -1. Let your code
on the command button set it to 0 to allow edits.

Then, use code similar to this in the form's BeforeUpdate event:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Cancel = Me.txtEdits
End If

You can change the value of the textbox at any time in any event.
 
Back
Top