keep button press from editing form

D

deb

I have a form called f000Score with 3 buttons
if button1 is clicked then Score field is 5
if button2 is clicked then Score field is 10
if button3 is clicked then Score field is 15

I have allow edit set to falsefor this form but when I click on any of the
buttons the Score field is changed. How can I prevent the buttons from
editing unless I click the edit button to allow edits.
 
D

Dirk Goldgar

deb said:
I have a form called f000Score with 3 buttons
if button1 is clicked then Score field is 5
if button2 is clicked then Score field is 10
if button3 is clicked then Score field is 15

I have allow edit set to falsefor this form but when I click on any of the
buttons the Score field is changed. How can I prevent the buttons from
editing unless I click the edit button to allow edits.


As you've discovered, AllowEdits = False keeps the user from editing the
record manually, but doesn't prevent your code from doing so. You can
either (a) disable or enable the buttons at the same time you set AllowEdits
to False or True, or (b) amend the code in each button to bypass the
assignment statement if the form's AllowEdits property is False.
 
D

Dirk Goldgar

deb said:
How can I enable/disable a button?


Set its Enabled property to False to disable it, True to enable it. For
example:

' Disable Button1
Me.Button1.Enabled = False

There's one hitch: you can't disable a control that has the focus. So if
one of these controls has the focus when you want to disable it, you'll need
to SetFocus someplace else first.
 
D

deb

How do i disable/enable the buttons they are on a sub form.

f000Score, f004PMScore, button name is ScoringCriteria1 and 2 and 3
 
D

Dirk Goldgar

deb said:
How do i disable/enable the buttons they are on a sub form.

f000Score, f004PMScore, button name is ScoringCriteria1 and 2 and 3

It would be better if you tell the relevant details when you first ask your
question.

In code operating on form f000Score:

Me.f004PMScore.Form!ScoringCriteria1.Enabled = False
Me.f004PMScore.Form!ScoringCriteria2.Enabled = False
Me.f004PMScore.Form!ScoringCriteria3.Enabled = False

Or, somewhat simpler,

With Me.f004PMScore.Form
!ScoringCriteria1.Enabled = False
!ScoringCriteria2.Enabled = False
!ScoringCriteria3.Enabled = False
End With

Both versions are assuming that "f004PMScore" is the name of the subform
*control* on the main form, the control that displays the subform, and not
just the name of the form object that it displays. You should check that
this is the case.
 
D

deb

Sorry, I should have said it was a sub form. I does make a huge difference

Thank you !!
 

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

Similar Threads


Top