Results 1 to 2 of 2

Thread: VBA Class Issue

  1. #1
    Join Date
    Feb 2006
    Posts
    46

    Unanswered: VBA Class Issue

    I have programmed in C# and VB.Net and I have a question about using classes in VBA as I am kind of new to it. I want to create a VBA Class called clsRecordset. As one of its properties, I want to have a property of type Recordset. The following syntax below, within my class module, does not cause my program to crash. However, I do not see the RecordsetData recordset in my intellisense.

    Private mRecordset As New ADODB.Recordset
    Public Property Get RecordsetData()
    RecordsetData = mRecordset
    End Property


    When I use the following code in my code, I see the RecordsetData property in my intellisense, but the VBA compiler is causing my code to crash.

    Private mRecordset As New ADODB.Recordset
    Public Property Get RecordsetData() as ADODB.Recordset
    RecordsetData = mRecordset
    End Property


    I basically want to have all of the properties of the Recordset object in my class so that I have access to the delete, update, and addnew methods available to my class. I have been able to get this to work within C# and VB.Net. Could someone please help?

    Thanks,

    Vipul

  2. #2
    Join Date
    Mar 2005
    Posts
    261
    In VBA you need to use 'Set' when assigning pointers (COM/automaton etc). e.g.

    Code:
    Set RecordsetData = mRecordset
    If you try to compile the code, it should pick up that mistake.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •