Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

@sort formula using ?sortfield parameter 1

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
This is driving me crazy now. Can someone PLEASE tell me why I'm told "A (datatype refering to the previous entry) is required here" after each table field datatype changes?!

Code:
    If {?sortfield} = "Title" Then
        {Pages.Title}
    Else
        If {?sortfield} = &quot;Author&quot; Then  // <-- up to here is fine
            {Person.Surname}
        Else 
            If {?sortfield} = &quot;Created&quot; Then // <-- up to here is peachy
                {KnowledgeBaseItem.CreatedDate}
            Else 
                If {?sortfield} = &quot;Update&quot; Then // <-- &quot;A string is required here&quot;
                    {Pages.UpdatedDate}
                Else
                    If {?sortfield} = &quot;Hits&quot; Then // <-- &quot;A datetime is required here&quot;
                        {KnowledgeBaseItem.Hits}
                    Else
                        If {?sortfield} = &quot;Category&quot; Then // <-- &quot;A number is required here&quot;
                            {KnowledgeBaseGroupSubtype.Name}
                        Else
                            {Pages.Title}

Pleeeeeease!! I've done so well today.. got Crystal working in .Net, got it passing parameters back to itself - now all I want to do is use the parameter &quot;?sortfield&quot; within the formula &quot;@sort&quot; (which is used as the Sort Order) to change the sorting of the results... :(

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Your problem is that an if-then must return the same datatype. You cannot have an if-then that says if condition A then text else date or if condition B then Date else Number.

To solve this convert everything to text like the following:

If {?sortfield} = &quot;Title&quot; Then {Pages.Title} Else
if {?sortfield} = &quot;Author&quot; Then {Person.Surname} Else
If {?sortfield} = &quot;Created&quot; Then totext((KnowledgeBaseItem.CreatedDate}) else
If {?sortfield} = &quot;Update&quot; Then totext({Pages.UpdatedDate}) else
If {?sortfield} = &quot;Hits&quot; totext({KnowledgeBaseItem.Hits}) else
If {?sortfield} = &quot;Category&quot; Then{KnowledgeBaseGroupSubtype.Name} Else
{Pages.Title}


Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top