Mouse Events with associated labels?

C

Clif McIrvin

Hi all-

I found parts of my answer in the archives, but am wondering if my
solution really is a 'good' one.

I have a form with a combo box (with enter and exit event procedures)
and a non-associated label (this lets me set up a On Click event for
the label.) (Several pairs, actually.)

When I was setting this up I considered using a command button but
settled on the unassociated label as it seemed to me to be "less
complicated."

Now, as I am putting the form into use I find that I'd like to set up
shortcut key access to the combo box.

The information I found in the archives was how to associate a label
with an existing control; but that lost my On Click event for the
label.

The solution I have arrived at, and that I'd like comments on, please,
is to keep both labels. The associated label has the shortcut key, and
the freestanding label has the On Click event.

To keep the form appearance, I formatted both labels identically
(including the caption with the shortcut key) and set visible=false
for the associated label.

This appears to be doing what I wish.

My question: is there a "cleaner" way to accomplish my objective?

Re-reading this post, perhaps this additional comment will be
helpful: Each pair of controls performs a lookup function. The user
enters the lookup criteria in the combo box, then executes the lookup
either by exiting the text box or clicking on the label. Keyboard
users will appreciate the shortcut key entry to the lookup text box
and the "tab" exit, and graphical oriented users will appreciate the
intuitave mouse clicks to select from a drop-down list of choices,
then execute the lookup.

Thanks for any suggestions!
 
A

Allen Browne

Cliff, that's a reasonable solution: an attached label that gives you the
hotkey you want, and the stand-alone label that gives you the Click event.

You can place the attached label behind the text box if it helps.

That assumes you want to do something in the Click event other than merely
set focus to the text box (which you can do without code.)
 
C

Clif McIrvin

Cliff, that's a reasonable solution: an attached label that gives you the
hotkey you want, and the stand-alone label that gives you the Click event.

You can place the attached label behind the text box if it helps.

That assumes you want to do something in the Click event other than merely
set focus to the text box (which you can do without code.)

Thanks, Allen. I'm glad to hear that I'm not totally confused, at
least! <g>

Yes, I do have logic associated with the click event which seems to be
working well.


However, I am running into another snag on this same form -- can I
determine what
triggered the exit event? Specifically, I'd like to be able to skip
the "on Exit" logic of
the text box if a command button on the form is selected, whether by
mouse click
or by hotkey.

I don't even know where else (other than here! <g>) to start looking
for the answer.
 
A

Allen Browne

Access processes the On Exit event of one control *before* it processes the
next control's events. So if you click on a command button (or tab out of
the control to the command button), the Exit event fires before there is any
next control.

Not sure what you need to achieve here, but you may need to rethink the
logic. For example, you can't put an undo button on a form and use it to
undo an invalid entry in a text box, because you can't get out of the text
box to the button while it has an invalid entry. A workaround for this is to
use the undo button on the toolbar instead of putting an undo button on the
form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Cliff, that's a reasonable solution: an attached label that gives you the
hotkey you want, and the stand-alone label that gives you the Click event.

You can place the attached label behind the text box if it helps.

That assumes you want to do something in the Click event other than merely
set focus to the text box (which you can do without code.)

Thanks, Allen. I'm glad to hear that I'm not totally confused, at
least! <g>

Yes, I do have logic associated with the click event which seems to be
working well.


However, I am running into another snag on this same form -- can I
determine what
triggered the exit event? Specifically, I'd like to be able to skip
the "on Exit" logic of
the text box if a command button on the form is selected, whether by
mouse click
or by hotkey.

I don't even know where else (other than here! <g>) to start looking
for the answer.
 
C

Clif McIrvin

Thanks again.

I have found some event timing issues in my code, and getting those
cleaned
up sure makes things work better!

I did modify the sequence of events, and I no longer have the
particular
issue that prompted my question.

One of my text boxes was controlling a "FindNext" sequence and I had
the
code setting the focus back to that control after each iteration --
that allowed
a single <tab> keystroke to trigger each iteration (after the first.)
My issue
happened if I wanted to invoke the "Review subform data" command
button
before I reached the final iteration, because of how Access process
events.

My solution was to set the focus to the command button, and make it's
exit
event "smart enough" to trigger the "FindNext" process when
appropriate.
Now I still have the single <tab> keystroke to step through
iterations, *and*
I can invoke the command button whenever I want to without generating
an
unwanted "FindNext."

On to the next step in the application development!

Thanks for the answers.
 

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