General information
Category:
Coding, syntax & commands
>I am using Crystal Reports in my VB6 app but cannot make it display the Crystal Report when the ORDER BY clause of the sql is attached.
>Following is the code, can you give me any suggestions?
>
> Dim qryEPA As String
> Dim sDate1, sDate2 As String
> Dim sLoc1, sLoc2 As String
>
> sLoc1 = frmEPA.cmbLocFrom.Text
> sLoc2 = frmEPA.cmbLocTo.Text
>
>
> qryEPA = "Select * "
> qryEPA = qryEPA + " FROM Epa_rate"
> qryEPA = qryEPA + " WHERE (Epa_rate.Location >='" + sLoc1 + "'"
> qryEPA = qryEPA + " AND Epa_rate.Location <='" + sLoc2 + "')"
>
> '*******THIS IS WHERE THE PROBLEM OCCURS *********'
> 'If the select case statements below are commented it works
> 'properly. But when it is included, why doesn't it work?
>
> Select Case frmEPA.cmbSortKey.Text
> Case "NAME"
> qryEPA = qryEPA + " ORDER BY Epa_rate.Name"
> Case "DIV_DEPT"
> qryEPA = qryEPA + " ORDER BY Epa_rate.Div, Epa_rate.Dept"
> Case "EFFDATE"
> qryEPA = qryEPA + " ORDER BY Epa_rate.EffDate"
> Case "ACTION"
> qryEPA = qryEPA + " ORDER BY Epa_rate.Action"
> End Select
>
> CrystalReport1.Connect = "DSN=PasDSN"
> CrystalReport1.ReportFileName = "c:\pas\epa_rating.rpt"
> CrystalReport1.SQLQuery = qryEPA
> CrystalReport1.Destination = crptToWindow
> CrystalReport1.WindowState = crptMaximized
You might want to try using a field number (position) instead of the field name as in ORDER BY 1,2.. etc.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only