Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    recordsource for form (2000 (SP3))

    I am working on a very slow loading form and changing its recordsource from being bound to a table to unbound and creating the recordsource in the OnLoad event of the form. When I do this, it works fine except I get 2 parameter prompts for the ID number. I am quite sure this has something to do with the 2 subforms since the parameter prompts disappear if I delete the subforms. Do I handle this in the recordsource code on the main form or write similar code for the subforms or what? <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>

    I would be delighted if someone could point me to a resource or the right direction for solving this. I have been able to find very few code examples of loading the recordsource in code (although I have found many suggestions to do this in terms of speeding up applications!)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: recordsource for form (2000 (SP3))

    You should make the subforms unbound too, and set the record source for the subforms in the On Load event procedure of the main form, AFTER setting the record source for the main form. For example:

    Private Sub Form_Load()
    Me.RecordSource = "tblCategories"
    Me.sbfProducts.Form.RecordSource = "tblProducts"
    End Sub

  3. #3
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: recordsource for form (2000 (SP3))

    Sounds like a plan. One final question before I give it a try.

    One of the subforms has a rat's nest of its own little subforms (not my design!). Should they all be unbound as well? And should they be referred to from the main form or from the subform?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: recordsource for form (2000 (SP3))

    Subforms have a tendency to start getting loaded before their parent form, so a bound subform on an unbound parent form will always cause problems. Hence, once you make the main form unbound, you should make all subforms unbound, and subforms of their subforms, etc.
    Set the record source for all of these in the On Load event of the main form, starting with the main form and working down level by level. It may be a nuisance, but it's necessary if you make the main form unbound.

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: recordsource for form (2000 (SP3))

    Another option is to still use a bound form (which allows you to use bound subforms), but restrict the size of the underlying recordset to a single record at a time rather than a full table. See this little article:

    Create Powerful Bound Forms
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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