My Form Will Not Respond To Me.AllowEdits

  • Thread starter Thread starter Tony Fairfield via AccessMonster.com
  • Start date Start date
T

Tony Fairfield via AccessMonster.com

I have a form were I changed the lock property to yes for every field to
keep Users from editing the data by mistake. The reason I locked every
field and not the form was to leave one field open to pick companyname and
bring up the record for that companyname. (I should also mention that I
have 2 subforms on this form and the queries and tables used are updatable).

I added an EDIT button to control the edits by prompting for a password.
When the button is clicked, it executes the following code:

Private Sub EditRcd_Click()
DoCmd.OpenForm "frmPswrdEdit"
Me.AllowEdits = True

End Sub

Is there something I'm missing?

Thanks for your help on this!!

Tony
 
Tony said:
I have a form were I changed the lock property to yes for every field
to keep Users from editing the data by mistake. The reason I locked
every field and not the form was to leave one field open to pick
companyname and bring up the record for that companyname. (I should
also mention that I have 2 subforms on this form and the queries and
tables used are updatable).

I added an EDIT button to control the edits by prompting for a
password. When the button is clicked, it executes the following code:

Private Sub EditRcd_Click()
DoCmd.OpenForm "frmPswrdEdit"
Me.AllowEdits = True

End Sub

Is there something I'm missing?

Yes, the fact that AllowEdits has nothing to do with the Locked property of your
controls. If you have individual controls set to Locked = Yes then your button
will have to execute code that sets all of their Locked properties back to No.

Pretty easy to do in a loop. I usually give all of the controls a common Tag
property ("Lock" for example) and then...

Dim cnt as Control

For Each cnt in Me
If cnt.Tag = "Lock" Then cnt.Locked = False
Next cnt
 
Hi Rick,
I changed all the field property tag to "Lock" and added your code to the
button. I received a run-time error "438 "object doesn't support this
property or method. It highlighted "cnt.Lock"

Is there something I forgot to add?

Thanks again!
Tony
 
okay, it works now, but only for the text boxes. It doesn't work for the 2
subforms. I changed the tag for them to "lock", but they are still locked
after running the loop.

Is there a way to unlock the subforms with this routine?

Thanks,
 
Tony said:
okay, it works now, but only for the text boxes. It doesn't work for
the 2 subforms. I changed the tag for them to "lock", but they are
still locked after running the loop.

Is there a way to unlock the subforms with this routine?

Thanks,

I just tested it on a subform and it worked fine for me.
 
I placed the code in beforeupdate and afterupdate, changing from true to
false. That worked for me.

I was stuck on this one. Your code really helped.

Thanks for your help!
Tony
 
Back
Top