Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Is my syntax wrong ?

Author  Topic 

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-08-16 : 04:50:54
I have following SQL which passes parameters to a Crystal report.

If I include this line

& " ORDER BY vweChaseFilesOUT.Dept"

I get the following error message

'The remaining text does not appear to be part of the formula.'

Ff I remove the ORDER BY line it works. Can anyone see my error ?



Case 1 'By Department
req.ReportState.RecordSelectionFormula = "{vweChaseFilesOut.Dept} Like '*" & strDept & "*' and" _
& " {vweChaseFilesOut.Division} like '*" & strDiv & "*' and" _
& " {vweChaseFilesOut.Sect} like '*" & strSection & "*' and" _
& " {vweChaseFilesOut.LastDateOut} in DateTime(" & SYear & "," & SMonth & "," & SDay & ", 00, 00, 00) to DateTime(" & EYear & "," & EMonth & "," & EDay & ", 00, 00, 00)" _
& " ORDER BY vweChaseFilesOUT.Dept"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-16 : 05:01:13
vweChaseFilesOUT.Dept should be within braces
It should be {vweChaseFilesOUT.Dept}

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-08-16 : 05:29:24
I tried that but it made no difference.....
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-16 : 05:32:30
I think you cannot do this because you are selecting records by passing values
You need to do this in your report
Open the report and set the sort field

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-08-16 : 06:11:51
Yes, I think I will have to do it that way. My select though is based on the sort order so I will have to have a separate report for each different sort order. Never mind !
Thanks for your help
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-16 : 06:22:13
If you are using CR8 then you can use CR.SQLQuery where you can write query with Order by Clause

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Pinto
Aged Yak Warrior

590 Posts

Posted - 2005-08-16 : 11:46:08
I am using CR9. I am a beginner though as you can guess so am not sure how to do what you suggest.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 02:34:19
In your Front End Application, you can declare

Dim CrRpt As CRAXDRT.Report
.
.

CrRpt.SQLQueryString="your query with order by"


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -