[AccessD] How to control subforms loading order?

Philippe PONS Philippe.Pons19 at wanadoo.fr
Thu Jun 5 13:00:06 CDT 2003


But I can't set the "source object" property of the second subform at this time since it is not yet loaded.
Attempting to reference this 2nd subform will generate an error.

I'm using this piece of code.
The main form is frmHistoMaint
The second subform is: sfrHistoMaintComment

Private Sub Form_Current()
'synchronisation de la zone de commentaire
Dim lHistoMaintId As Long
If Not IsNull(Me.HistoMaintId) Then
    lHistoMaintId = Me.HistoMaintId
    'an error occurs when sfrHistoMaintComment is not yet loaded
    'On Error Resume Next
    Form_frmHistoMaint.sfrHistoMaintComment.Form.SourceObject = "sfrHistoMaintComment"
    Form_frmHistoMaint.sfrHistoMaintComment.Form.Filter = "[HistoMaintId]=" & lHistoMaintId
    Form_frmHistoMaint.sfrHistoMaintComment.Form.FilterOn = True
ElseIf IsNull(Me.HistoMaintId) Then 'This is to have a blank form when no record are selected in the 1st subform
    Form_frmHistoMaint.sfrHistoMaintComment.Form.Filter = "[HistoMaintId]=" & 0
    Form_frmHistoMaint.sfrHistoMaintComment.Form.FilterOn = True
   
End If
End Sub

Thank's for your answer,

Philippe



  ----- Original Message ----- 
  From: John Colby 
  To: accessd at databaseadvisors.com 
  Sent: Thursday, June 05, 2003 5:36 PM
  Subject: RE: [AccessD] How to control subforms loading order?


  Yep, JIT loading.  The control on the form has a "source object" property.  Simply set this property for the second subform to nothing, then after the first subform loads, set the property of the second subform.

  John W. Colby
  www.colbyconsulting.com 

    -----Original Message-----
    From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Philippe PONS
    Sent: Thursday, June 05, 2003 11:19 AM
    To: AccessD at databaseadvisors.com
    Subject: [AccessD] How to control subforms loading order?


    Hi,

    I have a form with two embedded subforms.

    On the OnCurrent event of the first subform, I synchronise the second one using the Filter and OnFilter properties of it.
    This works fine, but generates an error the first time the Form is loaded.
    This is because I reference the second subform, but at this time it is not yet loaded.

    I found a workaround by removing the first subform from the main form and reinserting it, as it seems Access loads the subforms in the same order at which they have been inserted.

    However, I would like to have a more robust way of controling the loading order.

    Do you have a better solution?

    Thanks in advance,

    Philippe.



------------------------------------------------------------------------------


  _______________________________________________
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030605/ee30b6c5/attachment-0001.html>


More information about the AccessD mailing list