John W. Colby
jwcolby at colbyconsulting.com
Sun Mar 21 16:42:01 CST 2004
Yea, I'm in the process of building a class right now. :( John W. Colby www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Stuart McLachlan Sent: Sunday, March 21, 2004 5:22 PM To: Access Developers discussion and problemsolving Subject: Re: [AccessD] Storing custom datatypes in collections On 21 Mar 2004 at 14:27, John W. Colby wrote: > Has anyone ever succeeded in storing a custom data type in a collection? I > get an error message: > > "Compile error > > Only user defined types defined in public object modules can be coerced to > or from a variant or passed to late bound functions." > > This is the code I'm using: > > Public Type TblDat > strCnn As adodb.Connection > strTblName As String > End Type > > Public colTest As Collection > > Public Function SVTblDat(lstrCnn As adodb.Connection, lstrTblName As String) > As TblDat > Dim lTblDat As TblDat > Set lTblDat.strCnn = lstrCnn > lTblDat.strTblName = lstrTblName > SVTblDat = lTblDat > End Function > > Public Function TestCollection() > Set colTest = New Collection > colTest.Add SVTblDat(CurrentProject.Connection, "1234") > End Function > > Calling TestCollection and the error highlights SVTblDat( > > Anyone? > Same thing happens in VB. It's a known deficiency iin VB/VBA. Conventional wisdom is to use a class instead of a UDT. Try googling on "public object module" :-( -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support. -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com