DCount on Form - Error

fraser_lindsay

Access wannabe
Local time
Today, 19:04
Joined
Sep 7, 2005
Messages
218
Hello,

I am trying to set up a statistics summary of my database. Part of this is the number fo records counted in a query for various queries. I found this on the forum:


To show the number of records returned by a query, you can use the DCount() function.

Put a text box on the form. Put this in the Control Source property of the text box (using the correct query name):-

=DCount("*","queryName")



I have made a blank, unbound form and added a text box using this syntax above (with my query name).

However, I get an error in the box '#Name?' when I run the form.

Any suggestions?
 
Try,

=Dcount("[Fieldname]","[Queryname]")

you could also extend to criteria too if need be.
 
fraser_lindsay said:
However, I get an error in the box '#Name?' when I run the form.

Any suggestions?

I can only think that you have either mis-spelt your query name or you have an extra space that shouldn't be there.

Hay
 
count

Hi,

I might of lost the plot but, whenever I've writtern reports, I've done this...
if i want to count the number of "Items" on the report, I'd put a text box on the report and write:

count([Items])

where Items is then name of the field...
 
Count() will only work if the data is on the form itself. Dcount allows you to select an "external" source of data, i.e a query/table,etc
 
I've tried Kempes syntax and I get the same error. I've double and tripple checked the spelling and it's fine.

This box isn't for the report, I have one for each report. This box and amny other like it is for a form of statistics i.e. one form which shows the total number of employees for X and for Y and for Z etc.

It's meant to be a way of summarising the total number of employees which match a certain criteria (based on a query) in one place. So I can print it out as a summary sheet or make a graph or something.

This is the beggining of my jouney into some sort of statistical collation in my two recently built databases. Judging by my start, this is going to be a complete nightmare. I have some rather complicated stuff to get to.
 
Did you leave the speach marks "" in?

If you are using it for graphs, it might be better doing a crosstab query, but for displaying the figure on the form, the above info should work.
 
Ok if the spelling is all fine, I'd hazard a guess that you have a space before the =Dcount.
 
It was the quotation marks. I removed them from the "queryname" automatically in the first instance. Assuming that that just meant to input teh queryname in as [queryname].

Sorry, simple mistake to make. Got there in the end though. Thank you all for you inputs.

I won't bother any of you for at least the next 10 minutes.
 

Users who are viewing this thread

Back
Top Bottom