473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Q: What is the most efficient/fastest way to open a form?

Just a general question...

I'm currently using a combobox that when updated, opens a form with
its recordset based on a query using the combo box value as the
criteria.

I'm I correct in thinking that using:
docmd.openfrm "frmName",,,where "[ID]=" & cboSelectID
will open all records and then just navigate to that filtered record,
which is not as fast/efficient as using a query where the criteria is
set by a combo box?
Nov 12 '05 #1
6 3229
Unless the form is already open, the code:
Docmd.Openform "frmName",,,"[ID]=" & cboSelectID
opens the form with a Filter applied, so it contains only the one record (or
none if there is no match).

You can remove the filter to see the other records:
Me.FilterOn = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Just a general question...

I'm currently using a combobox that when updated, opens a form with
its recordset based on a query using the combo box value as the
criteria.

I'm I correct in thinking that using:
docmd.openfrm "frmName",,,where "[ID]=" & cboSelectID
will open all records and then just navigate to that filtered record,
which is not as fast/efficient as using a query where the criteria is
set by a combo box?

Nov 12 '05 #2
Allen, my question might need some clarification. I know the filter
opens the entire recordset and then has the form display the filtered
record. My question though relates to the speed of opening a form,
essentially.

So, I was wondering if using a query based recordset where the query
parameter criteria is based on a combobox is any quicker in opening a
form than using the standard wizard code (filter).

-John

"Allen Browne" <ab***************@bigpond.net.au> wrote in message news:<Go*********************@news-server.bigpond.net.au>...
Unless the form is already open, the code:
Docmd.Openform "frmName",,,"[ID]=" & cboSelectID
opens the form with a Filter applied, so it contains only the one record (or
none if there is no match).

You can remove the filter to see the other records:
Me.FilterOn = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Just a general question...

I'm currently using a combobox that when updated, opens a form with
its recordset based on a query using the combo box value as the
criteria.

I'm I correct in thinking that using:
docmd.openfrm "frmName",,,where "[ID]=" & cboSelectID
will open all records and then just navigate to that filtered record,
which is not as fast/efficient as using a query where the criteria is
set by a combo box?

Nov 12 '05 #3
You can run some timing tests on your own data, but in general, it's going
going to make much difference.

There are some advantages to opening the form so it only has one (or no)
record, and reassigning its RecordSource property so it only ever has one.
Filtering may be simpler if you load them all.

A well designed database will appear to load a form instantly if the first
record is available (i.e. there is an index on the fields used for criteria
or sorting). The remainder will load in "spare time", and when they are all
loaded, you will finally see the total count in the Nav Buttons. The user
can start working well before the final count is displayed. (This applies to
attached tables, or a form based on a query/sql statement.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Allen, my question might need some clarification. I know the filter
opens the entire recordset and then has the form display the filtered
record. My question though relates to the speed of opening a form,
essentially.

So, I was wondering if using a query based recordset where the query
parameter criteria is based on a combobox is any quicker in opening a
form than using the standard wizard code (filter).

-John

"Allen Browne" <ab***************@bigpond.net.au> wrote in message

news:<Go*********************@news-server.bigpond.net.au>...
Unless the form is already open, the code:
Docmd.Openform "frmName",,,"[ID]=" & cboSelectID
opens the form with a Filter applied, so it contains only the one record (or none if there is no match).

You can remove the filter to see the other records:
Me.FilterOn = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Just a general question...

I'm currently using a combobox that when updated, opens a form with
its recordset based on a query using the combo box value as the
criteria.

I'm I correct in thinking that using:
docmd.openfrm "frmName",,,where "[ID]=" & cboSelectID
will open all records and then just navigate to that filtered record,
which is not as fast/efficient as using a query where the criteria is
set by a combo box?

Nov 12 '05 #4
so*********@hotmail.com (John) wrote in
<90**************************@posting.google.com >:
So, I was wondering if using a query based recordset where the
query parameter criteria is based on a combobox is any quicker in
opening a form than using the standard wizard code (filter).


Well, this will all depend on how many records are returned by your
recordsource, how many by the filter, how big the PK index is and
how many records there are in the table.

Opening a form with DoCmd.OpenForm and using the filter argument is
just as fast as applying a filter on a form already open with all
records loaded in terms of the time it takes to load the data.
Loading the form definition itself is, of course, going to take
exactly the same amount of time.

My usual method is to do this:

1. the form has a recordsource that returns a blank, uneditable
record. I usually do this with a TOP 1 query on the smallest table
in the front end, and return NULL for all the fields that are
bound. A sample would look something like this:

SELECT TOP 1 Null As PersonID, Null As LastName, Null As
FirstName FROM tblSmallTable;

This accomplishes several things:

1. your controls can be bound.

2. the form is uneditable until you load a record.

3. since it's based on a small table, it's fast.

Once the form is loaded, you need some method for loading a record,
such as your combo box. However, instead of using bookmark
navigation to move to the record chosen in the combo box, instead
assign the recordsource to the form with a WHERE clause that
restricts the results to the one record.

I often also use text boxes instead of a combo box so the user can
type in a partial match and return more than one record. For
example, for looking up people's names, I'd have a FIND text box
and if someone puts in "Fen, D" it will return records with this
WHERE clause:

WHERE LastName Like "Fen*" And FirstName Like "D*"

It does mean that the LastName field can't have a comma in it. If
you need that, you could have separate LastName and FirstName
lookup textboxes. But I've used a single one in dozens of apps and
clients really like the ease of use.

This kind of approach scales extremely well and is fast. I've got
it working in apps with a range of a few dozen to 370K records in
the main table from which records are being returned. And these are
Access apps loading Jet data in a multi-user environment.

Speed is simply not an issue for these kinds of lookups.

As you well imagine, loading 370K records off the bat and then
filtering *would* be a major problem, and that's why I generally no
longer use bookmark navigation.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #5
RE/
Allen, my question might need some clarification. I know the filter
opens the entire recordset and then has the form display the filtered
record. My question though relates to the speed of opening a form,
essentially.

So, I was wondering if using a query based recordset where the query
parameter criteria is based on a combobox is any quicker in opening a
form than using the standard wizard code (filter).


My typical UI paradigm is a listbox on the left side of the form that shows all
records in the DB and detail fields on the right side of the form that only show
info for the record whose row is currently selected in the listbox.

Therefore I have the option of opening up the form with no data at all loaded
and waiting for the user to walk the list.

Actually, I usually pre-position the list so that the first record is selected
and loaded - gives the user a getter idea of what's going on.

Either way, forms like that open pretty quickly. For some reason, the size of
the listbox's list doesn't to have much impact one way or the other.
--
PeteCresswell
Nov 12 '05 #6
On 6 Oct 2003 23:53:25 -0700 in comp.databases.ms-access,
so*********@hotmail.com (John) wrote:
Just a general question...

I'm currently using a combobox that when updated, opens a form with
its recordset based on a query using the combo box value as the
criteria.

I'm I correct in thinking that using:
docmd.openfrm "frmName",,,where "[ID]=" & cboSelectID
will open all records and then just navigate to that filtered record,
which is not as fast/efficient as using a query where the criteria is
set by a combo box?


The only difference will be that using a query, the query will be
compiled (i.e. it's execution plan is saved) whereas using using the
where clause argument on OpenForm the execution plan of the
recordset's query will have to be calculated. The hit on the database
itself will be the same.

If you can tell the difference in execution time between using a saved
query and an ad-hoc one then your name is Data and you should be
concentrating on the LCARS system on the Enterprise and not fiddling
about with Access :-)

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: R U B'n | last post by:
Hi everyone, I have to make a (case-insensitive) search from a form with only one search string, e.g. "Doe Peters english California", which will search in several fields of my table for each...
9
by: Jiho Han | last post by:
Suppose I have an xml fragment like: <mother> <child name="Bob" sex="M"/> <child name="Jane" sex="F"/> ... </mother> If I wanted to replace the <mother> element to <father> element, what is...
18
by: Eirik WS | last post by:
Is there a more efficient way of comparing a string to different words? I'm doing it this way: if(strcmp(farge, "kvit") == 0) peikar_til_glas_struktur->farge = KVIT; if(strcmp(farge, "raud") ==...
1
by: Dennis Myrén | last post by:
Hi. There are a number of options how to iterate through the characters that make up a System.String; ToCharArray(), GetEnumerator or direct walkthrough from 0 to Length with indexing. I would...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
12
by: s99999999s2003 | last post by:
hi I have a file which is very large eg over 200Mb , and i am going to use python to code a "tail" command to get the last few lines of the file. What is a good algorithm for this type of task...
13
by: chrisben | last post by:
Hi, I need to insert more than 500,000 records at the end of the day in a C# application. I need to finish it as soon as possible. I created a stored procedure and called it from ADO to insert...
3
by: Jeff | last post by:
....another beginnger question. I have a web application in .net v2 VB that requires multiple reads from sql tables where each read is slightly different - so the sql select statements also differ...
8
by: secutos | last post by:
Programming Language: C#, .NET Framework 3.5 In this context, Form and App both describe a Microsoft Windows desktop application i'm creating. I'm creating a wordlist generator. I need to be able...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.