AllowEdits = False

J

Jose Perdigao

In Form_current event I did the following procedure

If Me.StatusXK < 80 Then Me.AllowEdits = False Else Me.AllowEdits = True

It works, but I have a problem. In this form, I have a combo box to filter
records. When the Me.AllowEdits = False I can't filter, I mean, I can't use
the combo box to filters.

There is way to protect the form (Me.AllowEdits = False ) and use the combo
box?

Thanks,
José Perdigão
 
A

Allen Browne

No. As you found, setting the form's AllowEdits property prevents you using
even the unbound controls.

The alternative is to prevent the edits by setting the Locked property of
each of the bound controls on your form. The code in this article
demonstrates how:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
 
S

SusanV

You could lock all the controls except the dropdown, rather than locking the
entire form...
 
J

Jose Perdigao

The combo box is unbound control, that's why I don't understand I can not
use it if the form is AllowEdits = False.

What would like is, every body can see all records, filtering but not edit.
some users can navigate over nabigation buttons and if the record is not
finish, they can edit if is finish they can not edit.

I try to use Me.RecordsetType =2 to protect and Me.RecordsetType =0 to edit.
It works good if I do this procedures in Form_Open event. If I put in
Form_Current event, spend time to go to next record, is like a brake.

Do you have any solution for my problem?

Thanks,
josé perdigão


What can I do this procedures
 
J

Jose Perdigao

I know this solution, but is very frustrate to create an envent for all
controls, I have many forms and each form have many bound controls.

Do you have anyasolution to quickly lock and unlock all bound controls? What
I know is, in Form_Current event typing something like this:

Private Sub Form_Current()

If Me!Finish = -1 Then
Me!A1.Locked = True
Me!A2.Locked = True
Me!A3.Locked = True
'...
Else
Me!A1.Locked = False
Me!A2.Locked = False
Me!A3.Locked = False
'...
End If

End Sub

Thanks,
josé perdigao
 
A

Allen Browne

Jose, there is no way to change the behavior of the form's AllowEdits
property so you can change unbound controls.

I did have a suggestion: a quite comprehensive function for you to copy and
paste into your database. In effect, it does what you suggested to SusanV in
your reply to her. But you don't have to write all that code for every form:
just call the code and loops through the controls on your form for you and
sets their Locked property.
 
J

Jose Perdigao

Thanks Allen,
Yes, I the code is short, it works good and it's easy to config the form.
But, when I click on the button to add new record comes the error 3314,
ChargeK cannot contain Null value because the Required property for this
field is set to True. I think this is because before I click on the button
to add new record, the field is locked. How can I solve this problem?

Thanks a lot

Jose Perdigao
 
A

Allen Browne

Sounds like the form is being dirtied too early.

For example, if you have something in the Current event of the form that
assigns a value to a bound control, you have begun the entry as soon as you
arrive at the control. This his highly undesirable, and once the new entry
has been started, it cannot be saved until the required fields are filled
in, validation rules met, and so on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top