Adding UDT (typed variables) to Collection fails

G

Gerry Verschuuren

What I tried to do is declaring a Public Type in a standard module in Access
2007: Public Type Employee
Name As String
DOH As Date
End Type.

Then I declared in the same module: Public colEmpls As New Collection.

Finally I created in the same module a Sub like this:
Public Sub(var1 As String,var2 As Date)
Dim utdEmpl As Employee
utdEmpl.Name = var1
utdEmpl.DOH = var2
colEmpls.Add utdEmpl

The code gets stuck on the last line. I know I could add utdEmpl.Name to the
Collection instead, but why can I not add utdEmpl itself? What should I
change to add the entire type itself to the collection (including its
members)?

Thanks for your help. Gerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top