ListBox selection

  • Thread starter Thread starter Imperator1969
  • Start date Start date
I

Imperator1969

Guest
Hi All

I'm a novice so please bear with me, my vba skills are still in their infancy. I've searched for a solution to my problem but nothing I found quite fits.

I have a form with a text field called txtSiteCode, there are many records attached to each Site Code. Next to this text box I have a button labelled "Select Site Code" that opens a form with a listbox of all Site codes in the DB, this is based on a query. I want to double click an item in the listbox, the listbox form to close, and the initial form to have the txtSiteCode field filled with my selection and the records to be filtered to that Site Code. So basically I'm replacing a find button with a custom find form where all the available entries are visible.

If anyone can help I would be very grateful.

Imperator
 
Use a Combobox instead of your text box and button. Base the rowsource of the combo on the query you are basing your list on.

This has the advantage of not needing an extra form and makes your app much slicker.

It would be slicker still if you based the combo rowsource on a SQL string and only seed the combo when it receives the focus, but that may be too much for you at this stage of your development.
 
Summerwind said:
Use a Combobox instead of your text box and button. Base the rowsource of the combo on the query you are basing your list on.

This has the advantage of not needing an extra form and makes your app much slicker.

It would be slicker still if you based the combo rowsource on a SQL string and only seed the combo when it receives the focus, but that may be too much for you at this stage of your development.

Thanks for replying. I took your advice and went for a combo box. It works perfectly. That's a lesson in how not to overthink a problem.

Cheers.
 

Users who are viewing this thread

Back
Top Bottom