
Q: Create custom property on form/report controls ?
Yup, you sure can, DAO properties that is. Try these routines...
' ****** Code Start *********
Private Function fGetDocObjectProperty(strObjectName As String, _
strObjectType As String, _
strPropertyName As String) _
As Variant
'?fGetDocObjectProperty("Module33","Modules","DateLastUpdated")
'
On Error GoTo ErrHandler
Dim db As Database
Dim doc As Document
Dim ctr As Container
Set db = CurrentDb
Set ctr = db.Containers(strObjectType)
Set doc = ctr.Documents(strObjectName)
fGetDocObjectProperty = doc.Properties(strPropertyName)
ExitHere:
Set doc = Nothing
Set ctr = Nothing
Set db = Nothing
Exit Function
ErrHandler:
fGetDocObjectProperty = Null
Resume ExitHere
End Function
Private Function fSetDocObjectProperty(strObjectName As String, _
strObjectType As String, _
strPropertyName As String, _
varPropertyValue As Variant, _
Optional varPropertyType As Variant = dbText) _
As Boolean
'?fSetDocObjectProperty("Module33","Modules","DateLastUpdated",Now)
'
On Error GoTo ErrHandler
Dim db As Database
Dim doc As Document
Dim ctr As Container
Dim prop As Property
Set db = CurrentDb
Set ctr = db.Containers(strObjectType)
Set doc = ctr.Documents(strObjectName)
doc.Properties(strPropertyName).Value = varPropertyValue
fSetDocObjectProperty = True
ExitHere:
Set prop = Nothing
Set doc = Nothing
Set ctr = Nothing
Set db = Nothing
Exit Function
ErrHandler:
Select Case Err.Number
Case 3270:
Set prop = doc.CreateProperty(strPropertyName, _
varPropertyType, varPropertyValue)
doc.Properties.Append prop
Resume Next
Case Else:
fSetDocObjectProperty = False
Resume ExitHere
End Select
Resume ExitHere
End Function
' ******** Code End ********
-- Dev
: Hi everyone
:
: I would like to know if it is possible to add a custom property to any
: control on a form or a report. I know it's possible for tables and dbs,
but
: I haven't found anything for form controls. The tag is useful, but we
can't
: put all the info we need into it.
:
: plmk if this is possible
:
: Thanks,
: Simon
:
:
: