View Full Version : Default value for Custom Property


Uncle Gizmo
01-22-2007, 01:13 AM
In MS Access custom properties can be created for Forms and Reports. sometimes a default value is necessary for a particular custom property.

In this example the property "prpCalendarFrm" is used to specify the calendar form to use when entering dates. The actual form used is named "frmCalendar" so this is the default value required.


'$$$$$$$$$$$$$$ --- Variables to set Default values --- $$$$$$$$$$$$$$$$$$$$$$$
Private strDefaultCalendarFrm As String 'Default Calendar Form

'############## --- Variables required for the property statements --- ########
Private mstrDefaultCalendarFrm As String 'Property set the Calendar form called by this form

Property Let prpCalendarFrm(strCalendarFrm As String)
mstrDefaultCalendarFrm = strCalendarFrm
End Property 'prpCalendarFrm Let

Property Get prpCalendarFrm() As String
If mstrDefaultCalendarFrm = "" Then
prpCalendarFrm = strDefaultCalendarFrm

Private Sub Form_Load()
strDefaultCalendarFrm = "frmCalendar"
End Sub 'Form_Load


In this instance it is occasionally necessary to use an advanced calendar form showing a whole year and this can be achieved by simply passing the name of the advanced calendar when you open the form like this:


Dim strFrmName As String
strFrmName = "frmContacts"

DoCmd.OpenForm strFrmName
With Forms(strFrmName)
.prpCalendarFrm = "frmYearCalendar"
End With