-
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?
-
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?
-
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
-
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.
-
new error
Object required at your recommended statement.
-
Suggestion
You must make sure 'm_def_totalRS' has been instantiated before UserControl_ReadProperties is called.