View Single Post
  #6  
Old April 24th, 2010, 01:00 PM posted to microsoft.public.access
Bob Quintal
external usenet poster
 
Posts: 939
Default Faster DCount or Query

=?Utf-8?B?UGV0ZXJN?= wrote in
:



"Jeff Boyce" wrote:

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"

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.





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.

"PeterM" wrote in message
...
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.



.