I've had a search and I realise there are some posts on this but I'm afraid I can't work out what's wrong.
I'm getting this error:- Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types
When compiling this (all in module):-
Public Type ShipSet
cPrice As Currency
sService As String
Public Function fSomething() As Variant
Dim Shipping(1 To 2) As ShipSet
Shipping(1).cPrice = 5
Shipping(2).cPrice = 10
Shipping(1).sService = "Ser1"
Shipping(2).sService = "Ser2"
fSomething = Shipping()
I'm afraid I don't understand the error message or how to resolve. For info, what I'm trying to achieve is pass a record reference to a function, and return an array (size unknown before running function) of the UDT (currency, string and integer values). I presume I could achieve this with:-
Public Function fSomething2() As Variant
Dim shipping(1 To 2, 1 To 2) As Variant
shipping(1, 1) = 5
shipping(2, 1) = 10
shipping(1, 2) = "Ser1"
shipping(2, 2) = "Ser2"
fSomething2 = shipping
But that's just using variants and I'm worried about memory and time (500k records to process).
Is there a way to achieve this using my UDT / why am I getting the error?