Access function returning a collection
Hey,
I have a VBA program in Access and I just created a new function.
I want it to return a collection of objects that I create inside the function.
Code:
Private Function GetADPOrderDetails(OrderID As Long, AgencyID As Long) As Collection
Dim blah As New Collection
Dim rs As Recordset
Dim sSQL As String
'some code
rs.Close
Set rs = Nothing
GetADPOrderDetails = blah
End Function
I am getting an argument not optional error and the GetADPOrderDetails = blah line is highlighted.
Can I not return collections in Ms-Access?
Thanks,
Re: Access function returning a collection
Re: Access function returning a collection
byref argument type mismatch error if I ommit the equal sign.
Re: Access function returning a collection
You need to
Code:
Set GetADPOrderDetails = blah
Re: Access function returning a collection
FYI, you could always just return the recordset. If you are going to be doing
any mods to the records in it, it may be helpful to have the rs instead of the collection.
Yes, Set is the the correct solution. :thumb: David
HTH