Which event to use?

I have a button on a form that is disabled by default.  I want to enable the button based on a Yes/No field in the DB record.  I use the standard navigation arrows at the bottom of the form to move forward and back in the table.

Which event do I use to put code to test the field and enable the button?.  Could I put something in the button Enabled property instead?
IBMJunkmanAsked:
Who is Participating?
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Two places.

Form Current event and the Yes/No field AfterUpdate event

mx
0
 
mbizupCommented:
Use the form's Current Event, which runs when the form opens and as the user navigates through records..

You should also use the After Update event of the field that is being tested.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
" I want to enable the button based on a Yes/No field in the DB record. "
Well, IF ... that field in not a check box on the Form (?), then you only need the current event.


Private Sub Form_Current()

Me.YourCommandButtonName.Enabled = (Me![YourYesNoFieldName] = True)  ' or False

mx
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
hnasrCommented:
Form_Current event for a filled field.

If you need to modify the field then, as mbizup commented, you need to use the same code in the Yes/No field after update event.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
"as mbizup commented, "

:-)
0
 
IBMJunkmanAuthor Commented:
Both options were used.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.