I'm working thru exercises in a book on access2019 programming. This bit of intro code to collections is not cooperating. I don't know enough to tell if it is correct or flawed.
EDIT to say that the "set" statement is what seems wrong. I replaced it with Dim collection myTestCollection as New Collection and all works fine.
grumble at the book editor.
i'll leave this rest here in case it helps anyone else.
I'm instructed to type this into the immediate window to begin.
#set myTestCollection = New Collection
#myTestCollection.Add"first member"
#myTestCollection.Add"secondmemeber"
#myTestCollection.Add"thirdmember"
#?myTestCollection.Count
first time - .Count results were 0
i erased and reentered it all again several times, and finally, I don't know what was different but got the expected count of 3.
Then I tried calling the one item and got the correct results.
myTestCollection.item(1)
then i tried the remove code
and when i recounted to verifty , the result was 1.
so i erased it all and typed it in again, and got 0 results on the Count.
i erase and type again and now i get a count of 4.
in this endless cycle of erase and retype I get inconsistent results every time.
here's the latest - why did the count go to four after the first Remove 1 line?
#set myTestCollection = New Collection
#myTestCollection.Add "first"
#myTestCollection.Add "section"
#myTestCollection.Add "third"
#?myTestCollection.Item(1)
#first
#myTestCollection.Remove 1
#?myTestCollection.Count
#4
#For Each m in myTestCollection : myTestCollection.Remove 1 : Next
#?myTestCollection.Count
#0
I've scrutinized code for typos, and fixed them when found. I can't find any more.
All ideas welcome.
thanks
Amy