Run code with any activity on form..

U

ucdcrush

I am stumped. What I am attempting to do is to write a block of code
that locks certain option boxes, nullifies others, and so forth, based
on the values of some other fields.

I know that I can do this as an afterupdate event for each form object
that affects whether another field should be locked or not. However, I
am trying to do this in one place if possible (i.e. write all the code
for locking or unlocking form objects).

The closest thing I've found is the timer, but while it's functional,
it does strange things appearance wise to the option group buttons,
like leaves them checked until the mouse is run over them.

I have also tried the form_beforeupdate event, but that only seems to
fire when I go to a new record. I want something to check if any
objects on the form have been updated, but without requiring switching
to a new record to fire.

Is there such a thing? By the way, I realize it's not the most
efficient thing programattically, i just want to know if there's a way.
 
D

Douglas J. Steele

There's really no good way to do what you want without using the various
events. However, that doesn't mean that you need to write separate code for
each event.

Write a generic routine (as a function, not a sub, even if it doesn't return
anything). Select all of the "data" controls on your form (i.e. the
checkboxes, text boxes, listboxes, comboboxes and so on, not the labels or
buttons). With all of them selected, look at the Properties window. Put your
function in the box associated with the LostFocus of each control as
=MyFunction() (include the = sign and the brackets). Now your code will run
every time you move from one control to another.
 

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