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?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
In which section of your Form are you placing this count?
 
Upvote 0
Forms and Reports have different sections, such as "Form Header", "Detail", "Form Footer".
What I am getting at, is if you are trying to get a total count, you would NOT put it in the Detail section, or else it will be repeated for every record.
You would want it in a Footer section.

So if you had 1000 records, and you put a DLOOKUP in the Detail section, you would be doing 1000 DLOOKUPs, which would be slow!
If you put it in the Footer, it will only be done once.
 
Upvote 0
Yes, In that case I have it in the "Detail". So you mean if I have DCount or DLOOKUP in the footer section it will be done only once?
 
Upvote 0
Yes.
The Detail section runs once for each record in your Record Source.
The Form Footer section only runs once, at the end, after you have cycled through all the records.
 
Upvote 0
It all depends on the structure of your Form and what these buttons are and what they do.
Typically, most Forms which have buttons to run queries are Unbound Forms (meaning that there is no record source attached to them). So it isn't an issue in that case.
If it was a Form bound to a multi-record Record Source, you would see the button multiple times if it was in the wrong section.
However, buttons don't do anything until you click them anyhow, so they really shouldn't slow anything down.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,431
Members
449,158
Latest member
burk0007

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