Results 1 to 6 of 6

Thread: How can I have a Property of Recordset in UserControl?

  1. #1

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    Question

    Hi, I'm passing a recordset to a usercontrol, and i like the usercontrol to have a recordset property. But I can't do it. It is not valid.

    ---------------------
    at form:
    set db = dbengine.opendatabase (...)
    set rs = db.openrecordset("anything")

    usercontrol.RS = rs

    -----------------------
    at usercontrol:

    public property get/let(byval m_rs as recordset)
    .....
    end property
    -----------------------

    the above won't work. Anyone know alternative to this, do i need to use DataMembers instead?
    It take a baby step for you to be here, nothing is impossible.

    v(^o^)v

  2. #2
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    What you need

    You need a property SET instead of a property LET for a start.


    You didn't mention how it failed? What was the error?

  3. #3

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    compilation error

    "Invalid use of property" at UserControl_ReadProperties


    Dim m_totalRS As Recordset


    Public Property Get totalRS() As Recordset
    totalRS = m_totalRS
    End Property


    Public Property Set totalRS(ByVal New_totalRS As Recordset)
    m_totalRS = New_totalRS
    PropertyChanged "totalRS"
    End Property


    'Initialize Properties for User Control
    Private Sub UserControl_InitProperties()
    m_totalRS = m_def_totalRS
    End Sub


    'Load property values from storage
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

    m_totalRS = PropBag.ReadProperty("totalRS", m_def_totalRS)
    End Sub


    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

    Call PropBag.WriteProperty("totalRS", m_totalRS, m_def_totalRS)
    End Sub
    It take a baby step for you to be here, nothing is impossible.

    v(^o^)v

  4. #4
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Try

    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

    SET m_totalRS = PropBag.ReadProperty("totalRS", m_def_totalRS)
    End Sub


    N.B. Note the addition of the keywork SET before assigning to the recordset object.

  5. #5

    Thread Starter
    Member engowen's Avatar
    Join Date
    Feb 2001
    Posts
    41

    new error

    Object required at your recommended statement.
    It take a baby step for you to be here, nothing is impossible.

    v(^o^)v

  6. #6
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Red face Suggestion

    You must make sure 'm_def_totalRS' has been instantiated before UserControl_ReadProperties is called.

Posting Permissions

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



Click Here to Expand Forum to Full Width