[AccessD] Framework Discussion - Disconnected labels

John W. Colby jwcolby at colbyconsulting.com
Sun Mar 21 04:54:41 CST 2004


>BTW it is possible to add controls to a control's control collection.

Never write at 10:30 pm.  As far as I have found, it is NOT possible to add
controls directly to the control's control collection, however we can
emulate that capability with our class which is what I am doing in this
email.

JWC

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of John W. Colby
Sent: Saturday, March 20, 2004 10:36 PM
To: AccessD
Subject: [AccessD] Framework Discussion - Disconnected labels


BTW it is possible to add controls to a control's control collection.  Thus
you can "TELL" a control in a continuous form that a label in the form's
header belongs to it.  I add a function to the class which assigns a label
out on the form to that control:

'
'Connects a label to a combo - used for continuous forms where the label is
in the header etc.
'
Function ConnectLabel(llbl As Label)
On Error GoTo Err_ConnectLabel
    Set mlbl = llbl
Exit_ConnectLabel:
Exit Function
Err_ConnectLabel:
        MsgBox Err.Description, , "Error in Function
dclsCtlTextBox.ConnectLabel"
        Resume Exit_ConnectLabel
    Resume 0    '.FOR TROUBLESHOOTING
End Function

Then, strictly for demo purposes I set and reset the label's backcolor in
the text boxes OnEnter and OnExit:

'
'These are the event stubs for the control's OnEnter and OnExit events
'
Private Sub mtxt_Enter()
    mlngBackColorOrig = mtxt.BackColor  'When we enter the text box, save
the original back color
    mtxt.BackColor = mclngBackColor     'Set the back color to our favorite
color
    mlbl.BackColor = 16744448
    mlbl.BackStyle = 1

End Sub

Private Sub mtxt_Exit(Cancel As Integer)
    mtxt.BackColor = mlngBackColorOrig  'When we exit the control, set the
back color back to the original color
    mlbl.BackStyle = 0
End Sub

In the form's Open event, after initializing the framework I call this
method and pass in a lable:

Public fdclsFrm As dclsFrm

Private Sub Form_Open(Cancel As Integer)
    Set fdclsFrm = New dclsFrm
    fdclsFrm.Init Me, Me
    With fdclsFrm.colClasses
        .item("txtCode").ConnectLabel lblCode
        .item("txtName").ConnectLabel lblName
    End With
End Sub

To see this functionality open the lfrmState and tab through the two
columns.  Again, this isn't particularly useful in this instance but it
might be a helpful indicator of cursor movement or state of a control and
again demonstrates that a disconnected label can be added to a control's
control class.

John W. Colby
www.ColbyConsulting.com


--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list