Trying to open form with onclick event of a combobox on a sub-form

SteveL13
SteveL13 used Ask the Experts™
on
I am trying to open form with an onclick event of a combobox on a sub-form IF the combo-box has a value in it.

I've tried these two things but neither of them will open the form if a value is in the combo-box I am clicking on: (Note:  The value in the combobox is text).

Private Sub cboPart_No_Click()
    If Me.cboPART_NO <> "" Then
        DoCmd.OpenForm "frmPOpricing"
    End If
End Sub


Private Sub cboPart_No_Click()
    If Not IsNull(Me.cboPART_NO) Then
        DoCmd.OpenForm "frmPOpricing"
    End If
End Sub
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
The On Click event of a ComboBox only fires when you open the drop-down and select (click) a item.

From your description: Maybe you should think about using the On Mouse Up event.
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Commented:
That wont work,
Keep your life simple,...just put a small button by the combobox and open the form with that same code.
This way you can *alert* the user of why it did not work.
If Not IsNull(me.combo) then
    msgbox "You must select a name."
    me.combo.setfocus
    ms.combo.dropdown
    exit sub
else
    docmd.open form "YourForm"
end if
If you absolutely "Must" do something like this, ...do it on the "Double-Click" Event.

Clicking a combobox, and having something happen  is not good UI design,
1. The click event of a combobox is rarely used.
2. Unless this is consistent for ALL comboboxes
3. User understand what will happen on all events of all controls.

For example, ...many user will "click" a control just for the sake of clicking it, .Just to set the focus to it.
In other words, ...user do not commonly expect anything to "Happen" when they click a combobox.

Imagine opening an app, ... and clicking a combobox opens a form
Setting focus to a control, ...opens a report
Hovering over a control, ...opens a query,
...doubleclicking an image, opens a new database...
Too much confusion over what happens when and under what circumstances

I just dislike putting code on "odd" events, ...because users never know what to expect.

Just my 2c...

JeffCoachman

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial