[AccessD] Classes, Recordsets, and problems inbetween

Charlotte Foust cfoust at infostatsystems.com
Mon May 12 10:26:02 CDT 2003


John,  I've passed ADO recordsets into functions as well.  It certainly
works if the argument is declared as an ADODB.Recordset.

Charlotte Foust

-----Original Message-----
From: John Colby [mailto:jcolby at colbyconsulting.com] 
Sent: Monday, May 12, 2003 4:23 AM
To: accessd at databaseadvisors.com
Subject: RE: [AccessD] Classes, Recordsets, and problems inbetween


Overloading definitely is not supported in Access VBA.

I have passed DAO databases and recordsets into functions so I know that
works.  I can't imagine that the same wouldn't work for ADO.

John W. Colby
www.colbyconsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Marcus
Tewksbury
Sent: Sunday, May 11, 2003 11:58 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Classes, Recordsets, and problems inbetween


Yeap

mrst has been declared...

Option Compare Database
Option Explicit

Private mlngInvoiceDetailID As Long
Private mlngInvoiceID As Long
Private mlngOrderDetailID As Long
Private mlngProductID As Long
Private mintShipped As Integer
Private mintCanceled As Integer
Private mintBackOrdered As Integer
Private mcurExtendedPrice As Currency
Private mflgSubstituteFlag As Boolean
Private mdteDateAdded As Date
Private mdteLastUpdated As Date
Private mflgActiveFlag As Boolean

Private mrst As ADODB.Recordset  <- Here
Private mflgAddFlag As Boolean
Private mflgDirtyFlag As Boolean

The problem seems to be directly related to passing a recordset into the
class - through a sub or function.  I've tried making

Public Function Load_byInvoiceDetail

a sub and function - and have tried passing byVal and ByRef.  For
testing I changed the paramter to (xrst as ADODB.recordset) and then
passed in a newly created, plain recordset and it still bombs.

Of course, another question that stems from this - if you look at what
my code is trying to accomplish - can you overload the initialize
method?  That would be helpful!

Thanks a million,

- Tewks





>From: "Michael R Mattys" <michael.mattys at adelphia.net>
>Reply-To: accessd at databaseadvisors.com
>To: <accessd at databaseadvisors.com>
>Subject: Re: [AccessD] Classes, Recordsets, and problems inbetween
>Date: Sun, 11 May 2003 23:09:37 -0400
>
>Marcus,
>
>Has mrst been set = to an ADO recordset
>in the Declarations section?
>
>Mike Mattys
>
>----- Original Message -----
>From: "Marcus Tewksbury" <tewksbum at hotmail.com>
>To: <accessD at databaseadvisors.com>
>Sent: Sunday, May 11, 2003 10:48 PM
>Subject: [AccessD] Classes, Recordsets, and problems inbetween
>
>
> > Hi everyone,
> >
> > Ok - here is my issue - I thought I'd be really fancy and start 
> > encapsulating my tables in data classes - using properites and all 
> > that
>good
> > stuff.  One issue that I am having is trying to pass in recordsets 
> > (or
>other
> > classes that also contain recordsets) into a class always gives me a
>Type
> > Mismatch or 438 error.
> >
> > The class files and code behind all reside in the same project.
> >
> > Any thoughts?  I'm stumped!
> >
> >
> > Here are 2 snippets
> >
> >     Dim oInvoiceDetail As New InvoiceDetail
> >     oInvoiceDetail.Load_byInvoiceID (Me.InvoiceID)
> >
> >     Dim oOrderDetail As New OrderDetail
> >     oOrderDetail.Load_byInvoiceDetail (oInvoiceDetail) <-CRASHES 
> > HERE
> >
> >     While Not oOrderDetail.EOF
> >         oOrderDetail.FilledFlag = False
> >         oOrderDetail.MoveNext
> >     Wend
> >
> > and ...
> >
> > Public Function Load_byInvoiceDetail(ByVal xInvoiceDetail As
>InvoiceDetail)
> >
> >     Dim sstrSQL As String
> >     Dim sflgNotFirst As Boolean
> >
> >     sstrSQL = "SELECT * FROM OrderDetail"
> >
> >     While Not xInvoiceDetail.EOF
> >         If Not sflgNotFirst Then
> >             sstrSQL = sstrSQL + " WHERE OrderDetailID = " & 
> > xInvoiceDetail!OrderDetailID & ")"
> >             sflgNotFirst = True
> >         Else
> >             sstrSQL = sstrSQL + " OR (OrderDetailID = " & 
> > xInvoiceDetail!OrderDetailID & ")"
> >         End If
> >         xInvoiceDetail.MoveNext
> >     Wend
> >
> >     With mrst
> >         .CursorLocation = adUseClient
> >         .CursorType = adOpenDynamic
> >         .LockType = adLockBatchOptimistic
> >         .Source = sstrSQL
> >         .Open
> >     End With
> >
> >     Call Scatter
> >
> > End Function
> >
> > _________________________________________________________________
> > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
> > http://join.msn.com/?page=features/virus
> >
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com 
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
>
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com 
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list