Susan Harkins
harkins at iglou.com
Fri Apr 4 09:35:55 CST 2003
Loop through the list items and set the Selected property to 0. I'm in the middle of putting up a new desk and all of by books and journals are everywhere but where I need them or I'd offer the actual code. I can't recall if it's Selected or SelectedItem. So, from Help: Selected Property See Also Applies To Example Specifics You can use the Selected property in Visual Basic to determine if an item in a list box is selected. Read/write Long. expression.Selected(lRow) expression Required. An expression that returns one of the objects in the Applies To list. lRow Required Long. The item in the list box. The first item is represented by a zero (0), the second by a one (1), and so on. Remarks The Selected property is a zero-based array that contains the selected state of each item in a list box. Setting Description True The list box item is selected. False The list box item isn't selected. You can get or set the Selected property by using Visual Basic. This property is available only at run time. When a list box control's MultiSelect property is set to None, only one item can have its Selected property set to True. When a list box control's MultiSelect property is set to Simple or Extended, any or all of the items can have their Selected property set to True. A multiple-selection list box bound to a field will always have a Value property equal to Null. You use the Selected property or the ItemsSelected collection to retrieve information about which items are selected. You can use the Selected property to select items in a list box by using Visual Basic. For example, the following expression selects the fifth item in the list: Me!Listbox.Selected(4) = True Example The following example uses the Selected property to move selected items in the lstSource list box to the lstDestination list box. The lstDestination list box's RowSourceType property is set to Value List and the control's RowSource property is constructed from all the selected items in the lstSource control. The lstSource list box's MultiSelect property is set to Extended. The CopySelected( ) procedure is called from the cmdCopyItem command button. Private Sub cmdCopyItem_Click() CopySelected Me End Sub Public Sub CopySelected(ByRef frm As Form) Dim ctlSource As Control Dim ctlDest As Control Dim strItems As String Dim intCurrentRow As Integer Set ctlSource = frm!lstSource Set ctlDest = frm!lstDestination For intCurrentRow = 0 To ctlSource.ListCount - 1 If ctlSource.Selected(intCurrentRow) Then strItems = strItems & ctlSource.Column(0, _ intCurrentRow) & ";" End If Next intCurrentRow ' Reset destination control's RowSource property. ctlDest.RowSource = "" ctlDest.RowSource = strItems Set ctlSource = Nothing Set ctlDest = Nothing End Sub ----- Original Message ----- From: "Gary" <gjgiever at yahoo.com> To: <accessd at databaseadvisors.com> Sent: Friday, April 04, 2003 10:25 AM Subject: [AccessD] Deselect all items from a multi-Select list box > I'm using Access97 on Windows XP. I have developed a > simple application to track which tables are used by > various applications that I have developed. The main > form has a multi-select listbox with all the tables. > The main form is bound to the table with all the > applications. I select all the appropriate tables for > the application in the listbox then a command button > adds all the selected tables to a third table that > lists all the tables for each application. > > My problem is that when i navigate to another > application all the tables that I selected for the > previous application are still selected. I can go > through and manually deselt each item or close the > form and reopen it. There must be an easier and more > elegant way to clear the listbox. I researched this > and found one other person who asked this question but > no one replied. It seems like it should be easy to > do. > > Gary J. Giever, MA > ACCMHS > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online, calculators, forms, and more > http://tax.yahoo.com > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > >