Faster DCount or Query

P

PeterM

I have a listbox on a form in AC2003 that counts the total number of entries
in a table.

Select count(*) from Medication

I execute the requery of the listbox after each record save.

My question is, is it faster/more efficient to continue using the listbox or
simply do a DCount?

Thanks in advance.
 
J

Jeff Boyce

Peter

Remember that forms (and listboxes) are only displaying what Access is
storing underneath in tables.

When you give us "SELECT Count(*) FROM Medication", we have to assume that
"Medication" is the name of a table. Is that correct?

So why are you using DCount() or a listbox or ... to count the number of
rows in a table? What business need are you trying to satisfy with that
number?

More info, please...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
P

PeterM

Jeff Boyce said:
Peter

Remember that forms (and listboxes) are only displaying what Access is
storing underneath in tables.

When you give us "SELECT Count(*) FROM Medication", we have to assume that
"Medication" is the name of a table. Is that correct?

yes, Medication is a table
So why are you using DCount() or a listbox or ... to count the number of
rows in a table? What business need are you trying to satisfy with that
number?

I have a listbox on the Medication Maintenance form listing all entries in
the Medication table so that users can click on an entry in the listbox and
go directly to that entry rather than nextrecord or previousrecord actions or
a search function. It's strictly a navigation tool. I use this method for
all maintenance forms where tables can have 100 - 200 records in it. This
way the user can scroll up or down to find the entry in the listbox, click on
that entry and the maintenance form populates with the info for that
Medication so the user can edit it. I use the dcount value in the label of
the listbox to show:

me.MedicationListboxLabel = DCount("*","Medication") & " Total Entries"
 
J

John W. Vinson

I have a listbox on the Medication Maintenance form listing all entries in
the Medication table so that users can click on an entry in the listbox and
go directly to that entry rather than nextrecord or previousrecord actions or
a search function. It's strictly a navigation tool. I use this method for
all maintenance forms where tables can have 100 - 200 records in it. This
way the user can scroll up or down to find the entry in the listbox, click on
that entry and the maintenance form populates with the info for that
Medication so the user can edit it. I use the dcount value in the label of
the listbox to show:

me.MedicationListboxLabel = DCount("*","Medication") & " Total Entries"

Well, the count will have to do a full scan of the table every time, so it
will indeed take time.

One question: why a Listbox which must be scrolled, rather than a Combo Box
with the Autocomplete feature turned on? The user could tab into it, type
"lov", and it would jump right to Lovastatin ('scuse me, I need to go take
mine...)
 
D

Duane Hookom

Why not just set the control source of your text box to:
=[lboMedications].[ListCount] & " Total Entries"
 
B

Bob Quintal

yes, Medication is a table


I have a listbox on the Medication Maintenance form listing all
entries in the Medication table so that users can click on an
entry in the listbox and go directly to that entry rather than
nextrecord or previousrecord actions or a search function. It's
strictly a navigation tool. I use this method for all maintenance
forms where tables can have 100 - 200 records in it. This way the
user can scroll up or down to find the entry in the listbox, click
on that entry and the maintenance form populates with the info for
that Medication so the user can edit it. I use the dcount value
in the label of the listbox to show:

me.MedicationListboxLabel = DCount("*","Medication") & " Total
Entries"
Consider replacing the listbox with a continuous subform. You can
format it to look like your listbox and you have the the row x of y
at the bottom.if you leave navigation on, use
me.recordsetclone.reccount to return your total rows.



 
J

Jeff Boyce

I vote with John's solution. A combobox takes up less room on the screen,
and does NOT require the user to scroll through a list of up to 200 items.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

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

Similar Threads

Access Dcount (multiple criteria) 3
Listbox Scroll Bar 1
Refreshing List box 2
Search Listbox vs Table Query 1
DCount works for one field but does not work with two fields 12
DCount Nulls 4
Listbox query 3
Dcount in query 4

Top