Form Layout - Design Question

GC2010

Registered User.
Local time
Yesterday, 16:08
Joined
Jun 3, 2019
Messages
120
I am populating a list box with the control source being a query. The query has a where clause added from VBA from the OnIndexChanged() event of a combo box above the list box.

So...when the form is opened the list box contains data for the last selection from the combo box because that is what the query holds. I do not want to set the list box to visible = true & visible = false from the selected index changed event of the combo box as that would look silly with a lot of whitespace between the combo box and the next control on the form.

Question at hand, how can I "clear" the listbox if the combo box is empty? (regardless of what the query shows). Maybe on formload() event delete the query, since it will be re-created on indexchange()?
 
are you sure that event applies to Access where you posted? Never heard of it, and google results turn up similar .Net and C# events, but not Access event.
If Access, something seems off - like why does a combo show a value when form opens? That's odd. If the combo is blank, the listbox rowsource should be such that the listbox shows nothing. I think that is key to your question, although it's predicated on the combo being blank at least when the form opens. Alternatively, a combo can have an "All" list item, which is typical, but you should not need a "None" item to force a listbox to show nothing.
 
Well, you could set the text wo white on open and change it to black after section. Then whether it's there or not on opening the Form no one will see it. Another choice would be to clear it on unload of the Form.
 
Well, you could set the text wo white on open and change it to black after section. Then whether it's there or not on opening the Form no one will see it. Another choice would be to clear it on unload of the Form.

How would I set the list box font color to white on FormLoad() then change it to black on the Leave() event of the combo box? What is the VBA for this?

I tried this, but the text color is still black when the form loads.

Code:
Private Sub Form_Load()
    List13.ForeColor = white
End Sub
 
Last edited:
First I believe it's vbWhite but you can Google that part. Then if the On_Load event is not working, might be too early, try the On_Open event. For the Combo Box it would be the After_Update event to turn vbBlack.
 

Users who are viewing this thread

Back
Top Bottom