I'm learning VBA on my own sort of as I go along, and I've been doing an okay job but I'm stuck on one thing. So far I have created a form with a list box that acts as a filter to a query. If you click in "cities" Yonkers, Woodside and Jamaica and then the filter button - only properties with those cities come up.
I want an "All" button or a condition that states that if none are selected, select all but I cant figure it out or find anything that works for me.
Here is my code right now:
Code:
DoCmd.RunSQL ("Delete * from cities")
For x = o To Me.CityList.ListCount - 1
If Me.CityList.Selected(x) = True Then
DoCmd.RunSQL ("Insert into cities values('" & _
Me.CityList.ItemData(x) & "')")
End If
Next
There is no way Im doing it the simplest, but it's working for me with this exception (I learned it from a video).
Cities is a Table seperate from my properties table (which has all information) - from what I can tell, based on the filter it lists only those selected.
CityList is the list box, pulling options from "All Cities" A query of every City through a group by function.
Many Thanks! If you need any clarification let me know and Ill try my best to respond helpfully!