Q: Create custom property on form/report controls ? 
Author Message
 Q: Create custom property on form/report controls ?

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



Sun, 22 Dec 2002 03:00:00 GMT  
 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
:
:
:



Sun, 22 Dec 2002 03:00:00 GMT  
 Q: Create custom property on form/report controls ?
Dev,

In reading through your routines, I fail to see how that will create
an additional property for a Control.  It looks to me that what is
created here is a property for a Document object (Form or Report), not
for the Controls in the object.  Am I missing something?

Marsh

Quote:

>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
>:
>:
>:



Thu, 26 Dec 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Create custom control in form using code (code wizard adding ocx to form)

2. Create custom control change property default

3. Crystal Report Custom Control - Not documented properties

4. Custom Property changes in Custom Outlook Form

5. Creating properties of custom properties?

6. Windows forms designer automatically adds code that sets properties of custom controls

7. VB 6 ActiveX Control in Windos Form, can't access any custom properties

8. My ActiveX Control loses its member property when attached to a custom Outlook Contact Form

9. VB6: Property Sheets Bug?, Custom Controls and properties

10. Creating custom methods for a custom control

11. Custom form to create and Standard form to display

12. custom form control: Cannot view design view of forms that inherit this form

 

 
Powered by phpBB® Forum Software