Dialog Form Enabling OK button

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Please help with a conceptual problem...

I have an unbound dialog form that I call up for the user to enter a
couple of values that will then be used for some calculations. I
don't want the OK button to enable until all the text boxes are filled
in. Normally, I would include a data check routine that would get
called from the afterupdate event on each text box. If all the text
boxes had a value (that was inside predetermined ranges), the OK
button would be enabled, otherwise not.

Pretty standard stuff...

Now, one pesky user has complained that after he's done entering the
last value the OK button doesn't enable until and unless he tabs off
the last text box. Sure enough, that's the way AfterUpdate works. He
wants it so that immediately upon entering a value in the last text
box, the OK button will enable. I got to say there is a certain logic
to that...

So, I've tried just about every event for the text boxes and form that
I can think of (dirty, keypress, etc), but nothing will fire. What
event should I be using to call the data check routine and enable the
OK button so that it reacts immediately to data entry and doesn't wait
for the user to move off the text box?

Thanks
 
What you need to do in the AfterUpdate event of the last textbox is enable
the button. Make sure that the button is in the Tab Order just after the
last textbox. (In Design View ... View >>> TabOrder) Then he can hit enter
twice and the button code fires.

The only other event that you can use is the Change event, which will fire
after the first character is typed in the textbox.
 
Arvin:

Thanks - your first suggestion is what I normally do, but the user
complains that lacks intuitive obviousness (i.e., he thinks that you
shouldn't have to move off the last text box to enable the OK button -
the mere act of entering a valid value in the last text box should
enable the OK button - I can't disagree with that viewpoint).

I tried the Change event, but the problem is that the text box doesn't
have a value yet (because the user hasn't move off it yet) so my data
validation fails. I'd normally just set the form.dirty = false, but
that doesn't work with unbound forms.

So, a slight reposing of the question... How do I get the currently
displayed text in a text box as it is being editted in an unbound form
without moving focus off the text box.

Thanks
 
IIRC, I think the value you're looking for is the .text value... so
ctl.text is the displayed (even if uncommited) value. So have in the
change event for the last control (the one he doesn't want to tab off,
which I don't blame him for).

If ctl.text <180 then me.button.enabled = true

(Obviously, changing names and criteria :D)

Hope that helps...
 
You must not have tied the Change event of the textbox. That fires with
every keystroke.
 
Back
Top