|
-
Jul 5th, 2006, 01:21 AM
#1
Thread Starter
Fanatic Member
Displaying a query
Hi
I am new to crystal reports and I want to display the result of a query executed in VB6 in crystal report.
the query is:
sql = "Select Top 20 PersonID From Member Group By PersonID Order By COUNT(*) DESC"
this query displays the top 20 persons who occur the most in the table Member.
Can anyone guide me through the steps to display my query?
Thanks in advance
-
Jul 5th, 2006, 03:30 AM
#2
Thread Starter
Fanatic Member
Re: Displaying a query
I am using VB6, Crystal report 9 and SQL server 2000.
I want to display the top 20 Persons in a chart,the full code I used to see who are the Top 20 persons who occur the most in the table Member:
VB Code:
Private Sub cmdshow_Click()
Dim sdate1 As Date
Dim sdate2 As Date
Dim sql As String
List1.Clear
sdate1 = Format(DTPicker1.Value, "Medium Date")
sdate2 = Format(DTPicker2.Value, "Medium Date")
sql = "Select Top 20 PersonID From Member inner Join Article on Member.ArticleID=Article.ArticleID where PDate between '" & sdate1 & "' and '" & sdate2 & "' Group By PersonID Order By COUNT(*) DESC"
Rs.Open sql, cnn, adOpenStatic, adLockOptimistic
Rs.MoveFirst
Do While Not Rs.EOF
Rs2.Open "Select * from Person where PersonID=" & Rs!PersonID, cnn, adOpenStatic, adLockOptimistic
sPerson = Rs2!PersonName
Rs2.Close
Rs1.Open "Select count(*) from Member inner Join Article on Member.ArticleID=Article.ArticleID where PDate between '" & sdate1 & "' and '" & sdate2 & "' and KeyID= " & Rs!PersonID, cnn, adOpenStatic, adLockOptimistic
nocc = Rs1(0)
Rs1.Close
ssPerson = sPerson& "-" & nocc
List1.AddItem ssPerson
Rs3.MoveNext
Loop
Rs3.Close
End Sub
The above code display in a listbox the Top 20 PersonName with their number of occurences.
e.g the listbox looks like:
John Smith- 2365 occurences
Sandra Lopez- 1595 occurences
...
What I want is generate a crystal report containing a chart that displays each PersonName and it's corresponding graph.(depending on his number of occurences)
I am new to crystal report so can anyone guide me?
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|