|
-
Dec 8th, 2004, 11:16 AM
#1
Thread Starter
Frenzied Member
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,
Don't anthropomorphize computers -- they hate it
-
Dec 8th, 2004, 11:20 AM
#2
Banned
Re: Access function returning a collection
-
Dec 8th, 2004, 11:28 AM
#3
Thread Starter
Frenzied Member
Re: Access function returning a collection
byref argument type mismatch error if I ommit the equal sign.
Don't anthropomorphize computers -- they hate it
-
Dec 8th, 2004, 11:34 AM
#4
Frenzied Member
Re: Access function returning a collection
You need to
Code:
Set GetADPOrderDetails = blah
-
Dec 8th, 2004, 12:35 PM
#5
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. David
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|