Re-setting combo boxes

B

Bill

I have several combo boxes that have values
selected under certain conditions. When the
user makes a certain change in those conditions,
most all of the combo boxes need to revert to
the same state they're in when the form opens,
namely blank. In the event code that gets
control with such a change, I have the following
form of code: (several such)

cmboMyCombo = Null

Sometimes the boxes clear and sometimes they
don't. What do I need to do to insure that they
always clear? I suppose if I Requery each one
that would do the trick, but intuitively that seems
excessive.

Bill
 
B

Bill

(PS)
I see that whichever of the combo boxes has the
focus that it will clear, but the others won't.
Bill
 
G

Guest

You will have to explicitly clear all the combos:
With Me
.Combo1 = Null
.Combo2 = Null
End With
 
B

Bill

Here's the code that runs where I'm having trouble:
(If I put a breakpoint at the "End With" and step
through the code, all the combo boxes "clear".
However, if I let the code run unabated, only
the combo that had the focus "clears", AND not
always that one.)
==============================================
Public Function MajCatSelect(strCategory As String)
Dim strTemp As String

strTemp = "lbl" & strCategory

If strMajCat = strTemp Then Exit Function

With Me
.CmboSubCat1 = Null
.CmboSubCat2 = Null
.CmboSubCat3 = Null
.CmboSubCat4 = Null
End With

Un_Highlight (strMajCat)
LCaseCat (strMajCat)
strMajCat = strTemp
Highlight (strMajCat)
UCaseCat (strMajCat) 'Set major category label to upper case

End Function
==============================================
What's going on here?
Bill
 
G

Guest

Without knowing what the functions that follow the End With, I couldn't say,
but if you breadk on the End With and the combos are clear, then that part is
working. Something else must be causing them to return to the previous value.
 
B

Bill

I've tried everything I can think of. In the code I
posted earlier, I commented out everything in that
function except the "= Null" statements, but still
the combos don't clear.

Operationally, the function runs when the user clicks
on a label control. The On_Click event for the label
has an invocation of the form:

"=MajCatSelect("ALL")"

So, having commented everything out except the
"= Null" statements, that means that in effect clicking
on any one of the labels of that type doesn't do anything
except attempt to clear the combos.

The application behaves the same when compiled in
both A2K and A2003.

I'm clueless at this point.

Bill
 
B

Bill

Very strange. The underlying RecordSource for the form
was based on a query that had several relational references.
The main or primary table contains record ID's of records
in the related table(s). There was a record in the main table
that had essentially invalid ID's that cause an empty
recordset to be returned by the query when the form opened.
I can't explain it much beyond that other than to say things
went downhill from there. With no records, that meant that
all of the combo boxes I was attempting to set Null were the
ONLY controls on the form that could obtain the focus, other
than the form itself. Whether that has anything to do with
what I experienced I don't know.

Anyway, the form is now behaving as it should and all of
the combo boxes clear as intended.

Bill
 

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