Click to See Complete Forum and Search --> : How can I have a Property of Recordset in UserControl?
engowen
Feb 13th, 2001, 02:40 AM
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?
simonm
Feb 13th, 2001, 02:51 AM
You need a property SET instead of a property LET for a start.
You didn't mention how it failed? What was the error?
engowen
Feb 13th, 2001, 03:25 AM
"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
simonm
Feb 13th, 2001, 04:08 AM
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.
engowen
Feb 13th, 2001, 07:15 PM
Object required at your recommended statement.
simonm
Feb 14th, 2001, 02:52 AM
You must make sure 'm_def_totalRS' has been instantiated before UserControl_ReadProperties is called.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.