Combo box On Click event doesn't fire.

M

Mr.Smith

Does anyone know why the On Click event for combo boxes in Access XP
(don't know about other versions) doesn't work?

Specifically...

Create a new form, add a combo box and add the following Event Procedure
for the On Click event.


-------------------------------------
Private Sub Combo1_Click()

MsgBox "Display something"

End Sub
-------------------------------------


Ensure that [Event Procedure] appears in the On Click event section of
the Properties window.

Now run the form and click the combo box. Nothing happens. No msgbox
appears and even if you set a breakpoint on any line in the code, it
doesn't break execution. As I said in the subject, the event doesn't fire.

I need the On click event specifically as the On Enter and Got Focus
events (which do work) are not appropriate for my requirement.

Any assistance will be caressed gently and taken for warm loving showers
as I'm not in favour of sloppy command button workarounds to force code
execution via user interaction.


Tah Love,
Mr. Smith
 
S

Sandra Daigle

It works, possibly not as you would expect but it does work as advertised
(or documented). Straight from help (abridged):

For a control, this event occurs when the user:

Selects an item in a combo box or list box, either by pressing the arrow
keys and then pressing the ENTER key or by clicking the mouse button.

I checked it in A2000 and A2002 and this is how it works. What is it that
you are trying to accomplish? Perhaps there is another way to do it. The
doubleclick event is one possibility that comes to mind.
 
M

Mr.Smith

Sandra said:
It works, possibly not as you would expect but it does work as advertised
(or documented). Straight from help (abridged):

For a control, this event occurs when the user:

Selects an item in a combo box or list box, either by pressing the arrow
keys and then pressing the ENTER key or by clicking the mouse button.

I checked it in A2000 and A2002 and this is how it works. What is it that
you are trying to accomplish? Perhaps there is another way to do it. The
doubleclick event is one possibility that comes to mind.


Thanks for the explanation on that. Would you agree that that
description reads more like an "OnSelect" event than an OnClick? As it
say, "SELECTS an item in a combo box or list box,...". Its a pretty naff
implementation of the OnClick event for my mind but what am I going to
do about it. Still maybe you can help with working alternative.

My exact requirement is this:

My app must be capable of working over a dial up connection. Many of my
forms contain a number of combo boxes sometimes as many as 9. As you
can imagine this can have consequences on a form's load time at 56k (40
realistically)

Therefore, when my forms load, I load them unbound and fetch records one
at a time to populate the form with. When it comes to my combo's, I
initialise each record displayed by setting the combo boxes
RowSourceType to "Value List" and build a 1 row list using values
contained within the populating record. (If those values are present)

What I want to do is change the combo box's RowSourceType to
"Table/View/StoredProc" then populate it with a proper list of options
when purposely clicked.

The reason for this is so that user can Tab across a combo without the
combo retreiving this option list, however if they *specifically* click
on a combo, its relevant data will load on demand. So as you can
imagine, Got Focus is not really appropriate, nor is On Enter, but a
Click on the drop down arrow is a natural usage. I find the Double
Click event kind of an ugly/klunky way to deliver this idea. If I have
to I have to but it just takes away from the intuitiveness on the
design. I've tried MouseUp, MouseDown too but found they work the same
way as OnClick.

This is an example of code relevant to the task:


Control code (What I would like the on Click to do):
-------------
Private Sub cboPositionLevelID_Click()

If Nz(Me.txtResourceID, "") <> "" Then _
FillComboBox "vw_ResourceCompanyNames"

End Sub


The function called that loads combo's on first use.
-------------
Function FillComboBox(strSQL As String)
On Error GoTo EH

Dim ctrl As Control

Set ctrl = Screen.ActiveControl

If ctrl.RowSourceType = "Table/View/StoredProc" Then Exit Function

ctrl.RowSourceType = "Table/View/StoredProc"
ctrl.RowSource = strSQL

DoCmd.Hourglass True
DoCmd.OpenForm "frm_Msg"
Forms!frm_Msg!lblMsg.Caption = "Creating List."
DoEvents

ctrl.Requery

DoCmd.Close acForm, "frm_Msg"
DoCmd.Hourglass False

Exit Function

EH:
Call ErrorMain(Err.Number, Err.Description, _
"mdl_FormFunctions - FillListComboBox")
End Function


So do you see what I am getting at?
 

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