B
Burnsie
I have created a user defined type that I want to store in a collection. I
have run into a couple of problems trying to store the UDT. First, the
collection will only accept the UDT as a string (maybe this really isn't a
problem). Secondly, when I retrieve the UDT from the collection, the only
info I get is what was last written to the UDT. For instance, if I reference
colMyAddress("Terry"), it returns myAddress. Then when I type
myAddress.Street, I get "8345 Sassafras Drive" instead of "2145 Cloverdale
Dr". If I put this UDT in an array everything is fine. But I want to use
the collection's ability to pull information based on the unique key.
Option Compare Database
Option Explicit
Public Type Address
Street As String
City As String
State As String
Zip As String
End Type
Public myAddress As Address
Public Sub LoadAddress()
Set colMyAddress = New Collection
myAddress.Street = "2145 Cloverdale Dr"
myAddress.City = "Colorado Springs"
myAddress.State = "CO"
myAddress.Zip = "80920"
colMyAddress.Add "myAddress", "Terry"
myAddress.Street = "8345 Sassafras Drive"
myAddress.City = "Marysville"
myAddress.State = "WA"
myAddress.Zip = "98271"
colMyAddress.Add "myAddress", "Jay"
End Sub
I appreciate any suggestions anyone has.
Thanks,
Burnsie
have run into a couple of problems trying to store the UDT. First, the
collection will only accept the UDT as a string (maybe this really isn't a
problem). Secondly, when I retrieve the UDT from the collection, the only
info I get is what was last written to the UDT. For instance, if I reference
colMyAddress("Terry"), it returns myAddress. Then when I type
myAddress.Street, I get "8345 Sassafras Drive" instead of "2145 Cloverdale
Dr". If I put this UDT in an array everything is fine. But I want to use
the collection's ability to pull information based on the unique key.
Option Compare Database
Option Explicit
Public Type Address
Street As String
City As String
State As String
Zip As String
End Type
Public myAddress As Address
Public Sub LoadAddress()
Set colMyAddress = New Collection
myAddress.Street = "2145 Cloverdale Dr"
myAddress.City = "Colorado Springs"
myAddress.State = "CO"
myAddress.Zip = "80920"
colMyAddress.Add "myAddress", "Terry"
myAddress.Street = "8345 Sassafras Drive"
myAddress.City = "Marysville"
myAddress.State = "WA"
myAddress.Zip = "98271"
colMyAddress.Add "myAddress", "Jay"
End Sub
I appreciate any suggestions anyone has.
Thanks,
Burnsie