hotcat
|
| Posted: 10/10/2002, 6:39 AM |
|
In the Tips & Articles IMRANZ wrote >>
---------- Start Quote --------------------
Give counting on your hands and feet a break! Here's a quick and easy tip for those of you who want to count records returned by a form in CC Studio.
This functionality will simply count every record returned by a form, so even if you have a search field that narrows down the amount of returned records, this RecordCount function will show an accurate count.
Counting Records in a Form In CCStudio (ASP)
Drop a Label field somewhere into your form's HTML from the Forms tab in the Toolbox. The easiest place is at the start of your form, right after the <!-- BEGIN Grid *yourform* --> section.
In the Data tab in the Properties, name this new field something like Counting
Set the Source Type as Code Expression.
Nothing in Control Source
Data Type of Integer
Nothing in Format
Put the Default value as: yourform*.datasource.Recordset.RecordCount()
*REPLACE 'yourform' above with the name of the form for which you're counting the records.
That's it!
------------ End Quote ---------------------
It is great and works very well first time for me :))
Please IMRANZ, could you add to the above and/or help me to also be able to COUNT FIELDS as easily as the above script.
Thanks very much
hotcat
|
|
|
 |
imranz
|
| Posted: 10/10/2002, 7:12 AM |
|
Glad it worked for you!
I'm not sure I understand your question.
|
|
|
 |
hotcat
|
| Posted: 10/10/2002, 11:55 AM |
|
Hello Imranz!
Ok, let me try to clarify.
I have a database for my Old School web site. Members sign in and submit various information.
01. Having used your 'counting sheep' scriptlet, when members go to the Old Boys Databse, they are told how many records (i.e. How many members have actually signed up) .. OK up to here.
02. What I am actually asking you is the following:
The databse has - among others - fields for 'Country' and 'Vintage' (the year they left school) and so on.
03. So what I would like also to do is to count and display with the Search Grid how many Old Boys are from UK, how many from USA AND also how many members are from the 1965 year, from the 1999 year and so on.
04. So that it would look something like this:
Members from: UK=25
USA=45
Vintage count: 1965=23
1999=12
2001=14
etc., etc.
Hopefully this is now more clear and you understand what I would like to do.
Your assistance would be most appreciated. I AM A NON PROGRAMMER!!
Thanks, have a good day.
hotcat
|
|
|
 |
skoolsout
|
| Posted: 10/10/2002, 3:37 PM |
|
silly question..which school... i went to chatham house in ramsgate in the early 70s..dont know if it even exists anymore
|
|
|
 |
imranz
|
| Posted: 10/11/2002, 7:21 AM |
|
Ah, I see. This one is almost as simple as the counting sheep example. What you actually have to do is pose an SQL query for each of these custom values you're looking for, and give the values a place to go.
The easiest way to do this would be to create a Label field for each of these values. Here's one as an example:
- Drop a Label field somewhere into your form's HTML from the Forms tab in the Toolbox. The easiest place is at the start of your form, right after the <!-- BEGIN Grid *yourform* --> section.
- In the Data tab in the Properties, name this new field something like CountMembersFromUK
- Set the Source Type as Code Expression.
- Nothing in Control Source
- Data Type of Text
- Nothing in Format
- Put the Default value as:
CCDLookUp("COUNT(*)", "YOURMEMBERSTABLE", "COUNTRY="&CCToSQL("UK","text"),DBYourCN)
NOTE: Replace YOURMEMBERSTABLE with, you guessed it, your members table name. And replace COUNTRY with whatever your field name is for country. And replace UK with whatever you use to designate UK as the country. And Replace DBYourCN with the name of your connection as used in CCS.
Basically, the CCDLookUp function is doing this sql query for you:
SELECT COUNT(*) FROM YOURMEMBERSTABLE WHERE COUNTRY=UK
And that should be it. You have to do this for each field for which you'd like to collect this special counting information. Just create a new label for each one, and adjust your sql query function accordingly.
I guess I'll add this to the counting sheep example :)
imranz
|
|
|
 |
hotcat
|
| Posted: 10/11/2002, 11:49 PM |
|
Imranz, OK I have implemenetd your code as posted AND IT WORKS!! THANK YOU.
There was only one small error:
You say [Replace DBYourCN with the name of your connection as used in CCS.]
I inerpreted it as replacing all the letters (whole word) "DBYourCN" meaning replace simply with "myconnectionnaame".
However, that did not work for me, so I experimented UNTIL "DBmyconnectionname" worked. THANKS AGAIN FOR YOUR HELP.
hotcat
|
|
|
 |
hotcat
|
| Posted: 10/11/2002, 11:49 PM |
|
Imranz, OK I have implemenetd your code as posted AND IT WORKS!! THANK YOU.
There was only one small error:
You say [Replace DBYourCN with the name of your connection as used in CCS.]
I inerpreted it as replacing all the letters (whole word) "DBYourCN" meaning replace simply with "myconnectionnaame".
However, that did not work for me, so I experimented UNTIL "DBmyconnectionname" worked. THANKS AGAIN FOR YOUR HELP.
hotcat
|
|
|
 |
|