Question : MS Access- populating first record on a form

Hi-
Is there any way I can populate the first record shown on my form to whatever the first row in my list box is (here's the catch) without the list box having focus?
Thanks,
Stacy


Answer : MS Access- populating first record on a form

Hi stacydr ...

I had a chance to look at your sample db.  I made some changes, please review the attached sample db that I uploaded.

In summary ...

1.) Changed the Companies List box to a Combo Box.
2.) Made the State, Vertical and Revenue List Boxes Multi Select so the user can select more than one item from each box if need be.
3.) After the user makes a selection in one or all three of the criteria boxes then click Apply Filter to filter the Companies list box.
4.) The code will always move the detail records to reflect the current company id selected in the drop down combo box.
5.) The concept uses three temp tables that basically stores any selections the user makes for state, vertical and revenue.  When you apply the filter, these selections are written to the temp tables and when the SQL is constructed for the Row Source of the lstCompanies combo box it will use the IN clause along with a sub query to pull the criteria from the temp tables.  I use this method because I build a lot of search forms and filters where the user can select a lot of items in a list box ... not just 4 or 5 but something like 30 or 40 states as an example.  Rather than trying to concatenate a SQL statement with 40 "OR" clauses, it's easier to say WHERE State IN(Select State FROM tblTempState).  

Give it a try using various criteria to filter the companies with and let me know if you have any questions.  You can also review the new code behind all the controls especially the Apply Filter and Remove Filter buttons.

ET

 
 
Client Sample DB
 
Random Solutions  
 
programming4us programming4us