[AccessD] Classes, Recordsets, and problems inbetween

Haslett, Andrew andrew.haslett at ilc.gov.au
Sun May 11 23:02:56 CDT 2003


lol - we've only finally got overloading and inheritance into VB.Net!  Very
doubtful we can do that in VBA.

I was about to ask if you've tried passing byRef so that ones out the door.

Another wild stab -> but I suppose this is still worth asking.  Haven't
forgot the references to ADO??

Perhaps try declaring mrst with a NEW instance:

Private mrst As *NEW* ADODB.Recordset

...but why would it work for InvoiceDetail and not OrderDetail??

Cheers,
A

-----Original Message-----
From: Marcus Tewksbury [mailto:tewksbum at hotmail.com]
Sent: Monday, 12 May 2003 1:28 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

IMPORTANT - PLEASE READ ******************** 
This email and any files transmitted with it are confidential and may 
contain information protected by law from disclosure. 
If you have received this message in error, please notify the sender 
immediately and delete this email from your system. 
No warranty is given that this email or files, if attached to this 
email, are free from computer viruses or other defects. They 
are provided on the basis the user assumes all responsibility for 
loss, damage or consequence resulting directly or indirectly from 
their use, whether caused by the negligence of the sender or not.


More information about the AccessD mailing list