Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends
I have a project and i need to put three fields on my data report namley
DEPARTMENT, SEX, TOTALPATIENTS

Here DEPARTMENT and SEX are fields in my data base table and TOTALPATIENTS is the calculated field (Alias) created with the following query
SQL
SELECT DEPARTMENT, SEX, COUNT(*) AS TotalPatients
FROM PATIEnts
GROUP BY DEPARTMENT, SEX
ORDER BY DEPARTMENT;


But i have a problem now.
When i put DEPARTMENT , SEX and TOTALPATIENTS as rptlabels and rtptextboxes on my VB6 data report it shows data field TOTALPATIENTS not found.
How to solve that.
Please help

Sarfaraz
Posted

1 solution

One possible solution is to create a view in the database using the select statement you are showing above. Then change the select statement in your application to select from the view. But you will not need the COUNT(*) in your application because it will be in the view. So all your application will see is the field names without an alias.

Another possible solution is to re-write the select in your application like this
SQL
SELECT DEPARTMENT, SEX, TOTALPATIENTS
FROM (SELECT DEPARTMENT, SEX, COUNT(*) AS TotalPatients
      FROM PATIEnts
      GROUP BY DEPARTMENT, SEX)
ORDER BY DEPARTMENT;


Another possible solution is that the VB6 data report is case sensitive. So you would either need to change the alias to "AS TOTALPATIENTS" or change the rptlabel to "TotalPatients".
 
Share this answer
 
Comments
sarfarazbhat 21-Dec-12 2:05am    
Thank you so much sir for your kind help.
Sarfaraz

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900