Understanding form loading on Open

Q

QB

1. If I understand properly. For a single form that is set to use as its
Record Source a table, it must load all the records in the table before
displaying the form.

2. What about form with subforms? Do the subforms do the same or do they
only load the data pertaining to the current link child master record?

I am interested in trying to optimize a form that has 20+ subforms and is
taking 10-20 seconds or so to load. I have read that I should remove the
default record source and populate the record source based on my lookup field
so it only has to access one record at a time. Does this make sense? What
else should I be trying to do to improve performance?

Thank you,

QB
 
D

Dorian

You should definitely not have your main form load all the records in a table.
I'd have a search form upfront that takes search criteria and displays a
list of records matching the criteria. Then a button to show the details of
an individual record and on that details form some navigation buttons tro
scroll thru the found records one at a time.
If you have 20 subforms on a form, it seems excessive. Are all the subforms
relevant in all cases to every record on the form?
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Q

QB

In this case, yes, there is a need for all the sub-form to get the full
picture for various tasks.

Thank you for confirming the proper approach!

QB
 
A

Albert D. Kallal

QB said:
1. If I understand properly. For a single form that is set to use as its
Record Source a table, it must load all the records in the table before
displaying the form.

No, the above is incorrect, and is even incorrect for when using sql server.

so, if you launch the form with an where clause (or a filter), and on your
cheap-o office network the table has 500,000 records, and you pass the where
clause with one ID, then ONLY the one record is pulled down the network
wire.

So

docmd.Openform "frmCustomer",,,"id = 34642"

This means you can safely use bound forms to the large table (or query -
makes no difference performance wise) as you have now. So, in the above
example the above from customer is bound, but ONLY the one record comes down
the network connection. this is the cause for a file share or when using
odbc to sql server.

2. What about form with subforms? Do the subforms do the same or do they
only load the data pertaining to the current link child master record?

Only the correct records pertaining to the current parent ID will come down
the wire.
I have read that I should remove the
default record source and populate the record source based on my lookup
field
so it only has to access one record at a time. Does this make sense?

No, it does not make sense, and it is the wrong advice.

What you do is place the sub-forms behind tab controls and simply don't load
the sub-form at all until the tab is clicked on. That way, if you have 1, or
2000 sub-forms the form load time will be the same. In this case, you will
set the source object of the sub-form control to the form you want to view.
Thus, no records for any sub-form not being viewed will not be transferred.
 
Q

QB

I understand your previous post, and thank you for explicitly explaining
certain aspects for me!

This brings up a question, probably a bad approach on my behalp. Right now,
when the user click on the button to open the form, it open the form and then
goes to a new record. So in fact, I do not filter to a new record (If I
understand correctly, with my current method it is loading all the records,
then goinf to a new one).

Since this is not the right approach, how could I load the form on a new
record without loading all the records? I can't filter for a non-existant
rec id in this case.

Also, assuming I open the form as you mentioned using a WHERE clause, how
then do I allow the user to move to another record using a cbo to make his
selection from? Do you close the form and reopen it with the new WHERE
clause or is there a simpler approach that I am missing?

Thank you for enlightening me.... again! And thank you for your time.

QB
 
A

Albert D. Kallal

This brings up a question, probably a bad approach on my behalp. Right
now,
when the user click on the button to open the form, it open the form and
then
goes to a new record. So in fact, I do not filter to a new record (If I
understand correctly, with my current method it is loading all the
records,
then goinf to a new one).

Yes you as a generally rule should try avoid opening the form without any
kind of filtering.

And of course all of these things are kind of kind of a best practices type
of thing. In some cases if your tables are small, then you have a lot more
leeway and don't have to worry about these details so much. I mean if you
dealing with a table with a few hundred records at most, then you don't have
to be so worried about the design issues. If you scale to more users or are
to have more records, then little issues can start to become big issues
quite fast.

In other words the culprit here is very much that the fact that you're
opening up a form without restricting records being loaded in the first
place. (and I think it's a good design or interest on your part to think
about these things).

As a general rule, I try to avoid the existence or even allowing navigation
buttons on a form that's bound to a table with many records. This don't
apply to sub forms. The idea here is is that if you can ask the user what
record they want to work on then you are in good shape. You then use open
form command with a where clause as I showed my previous post.
Since this is not the right approach, how could I load the form on a new
record without loading all the records? I can't filter for a non-existant
rec id in this case.

Actually believe it or not, I've seen some people actually open up a form
with a where clause that is a foolish one or impossible answer, for example
they use:

docmd.openform "frmCustomers",,,"id = 0"

Since the record ID will never be zero, then the above does actually prevent
records from being loaded into the form.

However, Access does a pretty smart job if you actually open up the form in
add mode. so, you can use:

docmd.OpenForm "frmCustomers",,,,acFormAdd

The real trick here though is to set up a system in which you always have
some type of prompt form to ask the user what customer or record they want
to work on in the first place. If the user does not find a result when
using that search form, it's also that very search form that has an add
button which then can launch the form in add mode as per above.

If you look at most applications, the first thing they do is present some
type of search box, you enter a search, get some type of hit list (results),
and then can pick from that list to edit the one record. These designs tend
to be more user friendly, but they also are more bandwidth or resource
friendly also.

Take a quick read of the following sample little article of mine, where I
explain this whole application flow concept:
http://www.members.shaw.ca/AlbertKallal/Search/index.html

One more benefit of this approach is to encourage your users to search for
something before they are presented with a form that allows them to easily
add a record. In other words it kind of a social engineering thing that if
you throw up a prompt a search for name, your users will be more inclined to
search before they just type in a new name without bothering to check the
current database if the names are already entered.
Also, assuming I open the form as you mentioned using a WHERE clause, how
then do I allow the user to move to another record using a cbo to make his
selection from? Do you close the form and reopen it with the new WHERE
clause or is there a simpler approach that I am missing?

Great question. Yes what I do is have the user close the form. (take a look
that above article).

I also find that the user feels better that they do one task with the phone
and dealing with one customer. They then close the form and they feel it
they'd done their job and they can move on to the next task at hand. Giving
your users a sense of completing a task or closure for one thing tends to
make them feel also better.
Thank you for enlightening me.... again! And thank you for your time.

You're very welcome. Remember what works for me and what works for you will
always vary. I do think if one can come up a design in which will ask the
user what they want before you toss up that form, you'll be building some
really nice applications and they will scale lot better.

And now that Access 2010 also has web creation ability, this philosophy of
design will serve you well in the future if you so choose to get into web
development using ms access.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top