| Access Database Tip: How do I multi select in a | | | | ctl.ItemData(selItem) & "'));" |
| List box? | | | | DoCmd.RunSQL (sql) |
| When you have a list box it is handy to be able | | | | Next selItem |
| to multiselect to perform some action on multiple | | | | SelCt = X |
| items in the list box. Here is a simple set of | | | | List0.Requery |
| instructions to get you started. These instructions | | | | ********** |
| will create a quick way to multiselect and delete | | | | Save the form |
| rows from a table. | | | | 7]Create a table with data for this example |
| Follow these steps: | | | | named "Tmpindextbl. " Make sure you have at |
| 1]create a simple form | | | | least one field named sFileName. |
| 2]add two text boxes named SelCt and LstCt | | | | You will need to add some dummy data for |
| 3]add a list box named List0 | | | | testing. |
| 4]on the list box properties form tab "Other" set | | | | You can download the example and the demo |
| the Multi Select to Extended | | | | mdb that accompanies this tip at. Getting the |
| 5]on the "Data" tab set | | | | example there will save you a little work. The |
| Rowsource type to Table/queryrow source to | | | | demo database also has a counter to show you |
| SELECT tmpIndextbl.sFileName FROM tmpIndextbl | | | | how many entries have been selected. |
| ORDER BY tmpIndextbl.sFileName; | | | | BioMation Systems, Inc provides process |
| 6]put this code between the *****on the "Event" | | | | improvement services that include solutions used |
| tab "After update" event | | | | by both large and small companies that are |
| ********** | | | | affordable and easy to use. Our products and |
| Private Sub List0_AfterUpdate() | | | | services are proven to enable our customers to |
| Dim ctl As Control, X As Integer, selItem As | | | | provide better service to their customers while |
| Variant, sql As String | | | | saving them money in the process. Our |
| Set ctl = List0 | | | | customers find that their return on investment is |
| For Each selItem In ctl.ItemsSelected | | | | most often realized after using their applications |
| X = X + 1 | | | | just a few times. |
| Debug.Print ctl.ItemData(selItem)sql = "DELETE | | | | What could BioMation Systems do for you? |
| tmpIndextbl.sFileName FROM tmpIndextbl"sql = sql | | | | Go ahead, take a look. |
| & " WHERE (((tmpIndextbl.sFileName)='" & | | | | |