문제

I have a table called TestTable with 3 fields called A,B and C

I'm trying to display on an Access 2003 report form the total number of records returned via a query in one textbox - Control Source set to "=Count(*)", and that works ok, and in another textbox display this value as a percentage of the total numbers of records, something like,

(Count(*)/total) * 100

But I'm having problems displaying the correct value in the second (percentage) textbox. I've tried setting a global variable to this value through the use of DCount("*", "TestTable") as part of an OpenRecordset Sub. This method works in the main user form however I can't seem to use such variables in a control source for this record.

Is there an easy way to do this?

도움이 되었습니까?

해결책

You can use DCount("*", "TestTable") directly! Why set a global variable?!

In the percentage textbox ControlSource property should be:

=(Count(*)/DCount("*", "TestTable")) * 100

BTW: If you set the Format property to Percent you can miss out the * 100

FYI: In order to access global variables from a ControlSource property you must use a function that returns the value of the global. Globals themselves are not accessible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top