What event occurs when a combobox is empty

darbid

Registered User.
Local time
Today, 07:30
Joined
Jun 26, 2008
Messages
1,428
I have a combobox which when the user chooses something makes a text field visible. This uses the after_update event.

It is possible that a user deletes his choice in the combobox. At the moment he does this I want the text field to disappear. At this point in time the after_update is only triggered if another control is choosen.

So what event is triggered when the contents of a combobox is deleted?
 
It is still the After Update event.

You might need to add a condition to your existing set of conditions, something like

Code:
If ....
     ....
ElseIf Len(Nz(Me.cboComboBoxName,0) = 0 Then
     Me.txtControlName.Visible = False
Else ...
End If

-dK
 
It is still the After Update event.

Thanks Dkinley for helping. Unfortunately I cannot agree with you. I put a Msgbox in the event to test when it is triggered. After text is choosen it is triggered. But upon deleting the text the first time it is triggered is when the cursor leaves the box. This only happens when another control is choosen.

You might need to add a condition to your existing set of conditions, something like

Thanks when I work out above I will also do this as well.
 
if that's the case, then it isn't being triggered because it's not been updated. - maybe try dirty/clean or entry/exit (or mouse/key up or down)
 
the after update events, etc fire when you save the combo box - ie exit the field

now there is a change eent, which will presumable trap keystrokes

so presumably in there you could say

if nz(mycombo,0)=0 then 'etc
(otherwise you would be doing sonmething with every keypress)

------
i think most people use the notinlist, limittolist, beforeupdate, afterupdate etc, to manage the combo box interaction - but try the change event and see what happens
 
Thank you guys again for taking the time.

I must have something else wrong, as it was annoying me so much I made a totally brand new DB with one form and a combobox and then put message boxes in every event to learn it myself.

The on change is what I established is correct. But the on change is not working on the form and combobox I am working on. So there is something else wrong.

When I find it I will post it. Of course if anyone would like to guess please let me know.
 
On Change works and I now have no idea why I even started this thread. I am an idiot. Oh well at least I know the ins and outs of combobox events :cool:

Edit:
Actually I have worked it out. The problem was and still is with the condition.

I have:
Code:
If Len(Nz(Me.reportbosscombo, 0)) > 1 Then
    do something
End If
The on change event is working. But the result does not. For example if I enter "ABC" this returns 3. If I then delete the "C" it still returns 3. In fact if I delete all of ABC it still returns three.

The rowsource is from a table. I have Limittolist = No.
 
Last edited:
Hmmm. Doing this on combo boxes can sometimes be tricky because of the bound column. For instance, the bound column could be an ID column but that column is hidden (0") and only displaying a name field for the user. In this instance you would need to either use an IsNull or = 0 of sorts if referencing the control, or, using the Len function as we have if referencing the name colum (cboName.Column(1)).

The difference being is referencing the bound column is the same as the control cboName is the same as cboName.Column(0).

Now, that is put in the language that is my head and not hardly technically correct but doe that make sense?

-dK
 

Users who are viewing this thread

Back
Top Bottom