Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Sydney, Australia

    Unanswered: Load Subform later


    Is there an easy way to prevent a subform from loading at the same time as the main form loads ?

    I'm trying to implement the following process ( may or may not work well with Access ).

    - user opens a form. There is no data, just a couple of unbound controls and a subform which is initially invisible
    - user sets a few options (e.g. checkboxes), and then clicks on a command button on the form
    - the command button starts some lengthy processing in an Sql 2000 database ( stored procedure )
    - if the stored proc completes successfully, it returns a short result set (statistics)
    - now, the subform becomes visible, and displays the recordset obtained from the execution of the stored proc

    So far, I had no luck in fully implementing this. Trouble is, the subform wants to display some data immediately when the main form opens. As a workaround, I used a separate Form instead of the subform, but then I'm running into communication problems between the two forms.

    Another workaround I've tried was to have some dummy data to satisfy the subform during the initial load. I created a view which returns a single constant row, e.g. "Error during processing". At design time, my subform displays this data. At run-time, if the stored proc returns prematurely, then it produces no result set, so I stay with the design-time content of the subform.

    All nice, but there is probably a simpler way for preventing the subform from loading upfront.

    Any ideas ? Is this scenario more VB-specific than Access ?

  2. #2
    Join Date
    Feb 2002
    Create a blank subform. In this example we can call it fsubBlank.

    Subforms use a sourceobject property to tell the main form which subform to load.

    So on opening your form set the sourceobject to fsubBlank. To do this the main form will have given the subform a name, prehaps tblStatistics or something. So the code could look like:


    When your form retrieves the information from SQL then you can recall the real subform as the sourceobject.


  3. #3
    Join Date
    Jun 2003
    Sydney, Australia
    Thanks Tiger,

    this makes sense and I will try it. Does "fsubBlank" need to exist as a separate form object in its own right ? I assume it must exist, because the only way I know to create a subform is to drag a an existing form into the design space of the parent.

    Later, when I set the sourceobject to the name of the real form, does this trigger an immediate Load ? I hope not, because I'd like to assign my own (compatible) recordset to it, or make it reload.

    Capitol Hill - Capital City
    Capitol Theatre - Capital Punishment

    Eastern states tend to be so pedantic.

  4. #4
    Join Date
    Dec 2002
    Préverenges, Switzerland
    yes - fsubblank needs to be a "real" form (it's a great place to post a logo or a copyright notice)

    yes - when you .sourceobject to the live form it will expect to find it's records

    if this doesn't fit with your game plan, you could consider defining your own (compatible) recordset in SQL, saving it as a querydef, and using that querydef as the recordsource of your live form. that way you can set up your recordset whilst fsubblank is showing.

    Last edited by izyrider; 08-18-03 at 03:40.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts