Count in Expression Builder in Access

ashwinghanta

Board Regular
Joined
Dec 6, 2011
Messages
118
I have a Query named Data and it has 5 fields A, B ,C ,D, E. The Field A has always distinct values. I have form with where I have an unbound textBox. Through the Expression Builder for the text box. I use
Code:
 [/FONT][/COLOR]<code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; background-color: rgb(239, 240, 241); white-space: pre-wrap; color: rgb(36, 39, 41);">Count([Data!A])</code>
. When I go to the form view it shows me
Code:
<code style="margin: 0px; padding: 1px 5px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; background-color: rgb(239, 240, 241); white-space: pre-wrap; color: rgb(36, 39, 41);">#Error</code>
.Where as the count in Query Data is 20. Where am I going wrong with the syntax?
 
I have tried with your idea of having DLookUp in the footer section. It still is very slow. Even normal Count(*) is very slow. I have about 6000 records in my main table. I made a query(L) out of it which has 4000 records and I have built up other queries around this main query (L). As the load increases on the main table the performance of the form specially(Count) (Max) (Min) (Avg) becomes really slow. How can I avoid this? and the normal Count([]![]) does not work in the textbox. it returns me #Error and Dcount works. What is the reason behind this?
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Exactly what kind of Form do you have?
Does it just show one record per screen, or is it a Continuous Form?
What exactly do you use it for?
Why do you have totals on there?

Just trying to figure out if you should maybe be using a Report instead of a Form, but in order to determine that, I need more details.
 
Upvote 0
form_zps0agoywqe.png
[/URL][/IMG]

This is how my form looks like. Where we enter dates in the von and bis text fields and click on aktivieren which has me.refresh behind. Then it would fill out the text204 and Maximum, Minimum and Durchschnitt textboxes. The buttons beside text204 would open queries. Now these dates are based on the main Query(L). It has 5 different fields A,B,C,D,E.The field A is a date field. So
Code:
Lau.A is between forms!start and forms!end
for the query Summe der Antrage.
Code:
WHERE E = 1 AND Lau.A is between forms!start and forms!end
is for query Dunkel.
Code:
WHERE E = 0 AND Lau.A is between forms!start and forms!end
is for query Schwebe and Status offen is the difference between Summe der Antrage And (Dunkel+Schwebe).So I need to Count these queries in those text boxes. Count[]![] doesn't work in those text204 either Dcount or Dlookup works. I tried to create another Query which counts these queries. So that I could make it Bound to this form. That doesn't work either. It shows 0 in all text204 fields. Also the Query which Counts all other Queries takes a lot of time to run. How can I simplify this Count so that it runs smoothly?
 
Upvote 0
Without having access to your database, I don't think there is much more I can do.
 
Upvote 0
Be sure that your table is correctly indexed (i.e., the search fields or fields used as conditions in where clauses).
In general, try to avoid doing a query twice - if possible. In the extreme, store the results of Min/Max/Avg so you can reuse them as a simple variable rather than having to do the whole query again. In the extreme of the extreme, put everything into a temp table so you can work from a smaller table rather than from the larger main table.

BTW its not clear what you mean by a query that counts all the other queries. Do you mean the sum of all the record counts of all the queries?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,363
Messages
6,124,505
Members
449,166
Latest member
hokjock

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top