Defining a Class to Select Instances
Posted on 2016-09-21
I want to define a class in which I can open a form with two listboxes side by side. The user will be able to double click an item in one listbox to move that item to the other listbox. The listbox to the left will be unselected items, and the listbox to the right will be selected items. I want to fill a generic recordset with fields "PKid", "instancename", and "selected" and open the form with that recordset. "Selected" is a Boolean field. Any records with selected = True will show in the listbox on the right, otherwise the record will show in the listbox on the left. Double clicking an item will toggle the selected field for that record and requery the listboxes. In some cases I'll fill the recordset with Employees from the Employees table so users can select a group of Employees, in other cases I'll fill it with Operations from the Operations table so the users can select a group of operations, etc. When the form is closed by the user I'll have a recordset of elements of which I'll know which ones were selected by the user.
To accomplish this, would I have a class called "Selection" with a Recordset property and a "SelectInstances" method to open the form? How would I define the fields in the recordset and fill the recordset with the data from a SQL statement or stored procedure?