Log in

View Full Version : copy problem



eran3185
06-30-2007, 06:52 AM
i have a query and i use "count" to get the number of items i have.
then i want to see this number in a form , and i put text box that receive this number.
the problem : i get "#Name?" in my text box
why ?

OBP
06-30-2007, 08:03 AM
eran, ensure that you have spelt the field name correctly, is it "countoffieldname" where fieldname is the name of the field in the query that is being counted?

eran3185
06-30-2007, 08:16 AM
i think the name is correct , i try to count the number of id's in the field - "id"

OBP
06-30-2007, 08:40 AM
I think that the name in the Field on the Form should be "CountofID" not ID.
Can you post a copy of the database?

eran3185
06-30-2007, 08:51 AM
hey
there is a litlle example.
look at the field "test" in the form

OBP
07-01-2007, 06:50 AM
eran, the reason that you cannot get the ID count in your Form's field is because the Form's Data Source is the Table called table1. The value from the Query query1 is not available.
There are 3 ways to achieve what you want to do.
1. Create a form based on query1 and add it as a Subform. I have done this and added the subform to the Header, Footer and Details in the Attached database, you can choose where you would like it.
2. Create a Query that has all the fields from table1 and the count of id, create a form based on this Query. Add a text box field to the Form Footer which uses the "=Sum([Countofid]) as it's record source. This is also in the database as Form "table1 query".
3. Use VBA with a Recordset based on the Query query1 and use it to add the value to a text box on your form. I have added this version to the database as Form "table v2" but I could not get this version to work with my version of Access VBA. :dunno So I removed the VBA.