MS Access: ComboBox is populated via VBA but items won't show

Shadi Saleh
Shadi Saleh used Ask the Experts™
on
I have a form that contains a subform.

In the form I have a search box and a search by combobox.

The search by combo box should be populated with the searchable fields on the subform.

I write a simple vba code that I can see it does its job, but the the problem is that the combobox is still empty.

A showcase tiny database is attached.
ShowCase-.accdb
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Adjust your filter to include what you search for:

strFilter = Me.Search_By_combo.Value & " Like '*" & Me.Search_For_Box.Text & "*'"

Open in new window

/gustav

Author

Commented:
@Gustav Brock: Thanks for this  important -yet aside-  note.

Hope you can help with finding out why the combobox won't show items after being populated. The only value that could appear is First Name because I chose it as a Default value from the design view mode.
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
That's because you have set property ColumnWidth of the combobox to 0 (zero).
Clear it.

/gustav

Author

Commented:
What a behaviour of Access!

Thanks a lot Gustav. The was really helpful, really pro and really expert.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
Thank you. You are welcome!

/gustav

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