Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list box, select all

Status
Not open for further replies.

luceze

Programmer
Apr 26, 2001
842
US
I have tried without success to create code to select all values in a list box but can't seem to get it to work. I can loop through selected items but don't know how to loop through all the items in the listbox.
 
Private Sub cmdSelectAll_Click()

DoCmd.SetWarnings False

Dim db As DAO.Database

Set db = CurrentDb

db.Execute "UPDATE [tblName] Set [ViewDocument]=Yes"

Me.Refresh

DoCmd.SetWarnings True


End Sub
 
The control source of my listbox is a query. Does that make a difference? I get an error for expected parameters.
 


I got this to work. But I am curious what your code does.

Private Sub cmdSelectPost_Click()
Dim i As Integer

For i = 0 To ChoosePost.ListCount - 1
ChoosePost.Selected(i) = True
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top