Default value for Custom Property (1 Viewer)

Status
Not open for further replies.

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 23:25
Joined
Jul 9, 2003
Messages
16,282
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.

Code:
'$$$$$$$$$$$$$$ --- 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:

Code:
Dim strFrmName As String
strFrmName = "frmContacts"

   DoCmd.OpenForm strFrmName
    With Forms(strFrmName)
        .prpCalendarFrm = "frmYearCalendar"
    End With
 
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom