Unbound combo box is clear after making selection (1 Viewer)

slharman1

Member
Local time
Today, 00:52
Joined
Mar 8, 2021
Messages
476
I have a form that shows all records in a query, one field is called ProductType, In the header I have an unbound combo box that gets records from the product type table and filters the detail section of the form (all records) to the selection in the combo box. All is working fine but once i select the field in the combo box it filters as it should but the combo box is blank, is there a way to keep the selection visible after being selected?
Also is there a way to add "All" or "Clear Filter" to the combo box?
Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:52
Joined
Oct 29, 2018
Messages
21,496
Can you post the code behind the unbound combobox? Maybe there's something in there that's clearing up the combo.
 

LarryE

Active member
Local time
Yesterday, 22:52
Joined
Aug 18, 2021
Messages
592
1712932855046.png

Check the combo box properties settings. The first column may be a 0" length (as in the example above). If the combo box works as intended, then it is not really blank, the bound column is just not visible. In the example above, the first column is not visible but the second and third are, so when the combo box dropdown is activated only columns 2 and 3 show, but column 1 is the bound column.

As for clearing the combo box, I use a command button that when clicked just clears the combo box:
Me.COMBO BOX NAME = Null
 

slharman1

Member
Local time
Today, 00:52
Joined
Mar 8, 2021
Messages
476
Can you post the code behind the unbound combobox? Maybe there's something in there that's clearing up the combo.
I think I've figured out why it is clearing, I am using it to filter the form so I believe it clears the combo box after the filter is applied and re-paints the screen with the filtered records - does that make sense? The combo box was made using the wizard. and gets it's value from a table, is it possible to add "all" to this combo?
Thanks
 

slharman1

Member
Local time
Today, 00:52
Joined
Mar 8, 2021
Messages
476
View attachment 113678
Check the combo box properties settings. The first column may be a 0" length (as in the example above). If the combo box works as intended, then it is not really blank, the bound column is just not visible. In the example above, the first column is not visible but the second and third are, so when the combo box dropdown is activated only columns 2 and 3 show, but column 1 is the bound column.

As for clearing the combo box, I use a command button that when clicked just clears the combo box:
Me.COMBO BOX NAME = Null
This is what i have. The primary key from the table the combo is looking up is the first column and 0 length. When I say the combo is clear after selection is made I mean it is blank but applies the filter.
 

tvanstiphout

Active member
Local time
Yesterday, 22:52
Joined
Jan 22, 2016
Messages
232
> Also is there a way to add "All" or "Clear Filter" to the combo box?
Yes, by changing the RowSource to a union query. Example.
 

slharman1

Member
Local time
Today, 00:52
Joined
Mar 8, 2021
Messages
476
> Also is there a way to add "All" or "Clear Filter" to the combo box?
Yes, by changing the RowSource to a union query. Example.
Easy enough but...I am using the FilterByControl method in VBA to filter the records on the form and when I select the "All" selection I get the error that no items match "All" on my form.
How do I use a if then in VBA to remove the filter?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:52
Joined
Oct 29, 2018
Messages
21,496
Hi. Please, feel free to ignore my earlier post. Good luck!
 

LarryE

Active member
Local time
Yesterday, 22:52
Joined
Aug 18, 2021
Messages
592
1712938885554.png

Try changing the bound column to 3rd column with a 0" length. Just showing the first 2 columns in the dropdown.
1712939165471.png
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:52
Joined
Oct 29, 2018
Messages
21,496
If you’ll look, you’ll see that I responded to your post. Thank you.
Right, but without seeing the code you're actually using, then we're only guessing why things are happening as you described. If you've already fixed the original problem of why it's clearing the input, then that's good. Otherwise, if you still need help with that, then posting the code might help get to an answer quicker. Saying the code was created by the wizard doesn't confirm that additional lines of code didn't accidentally get inserted in it. Hope that makes sense...
 

Users who are viewing this thread

Top Bottom