MasterData Asceding by...

edited 9:24AM in FastReport 4.0
Hello, I have a MasterData with 8 fields. 6 of them are subreports and two of them are text objects. The first one is Surnames of customers and they are printing on my report asceding by their name. But I want them to be apperaring asceding by their sales which is the other text box of my MasterData. How can I do that? Thanks.

Comments

  • stefquestefque Serbia
    edited 9:24AM
    How about changing the query, and adding "order by salery" at the end, then the query would return them sorted...
  • edited 9:24AM
    I can't do that because the field I want to sort is a calculated field and it is quite complex calculated so I can't use it in my query.
  • edited 9:24AM
    Does your database allows temporary tables?

    If so, then insert the result of your main query into a temp table and your much calculated field will become a standard column. And then use another query reading from this temp table with sort order that you need.

    Mick
  • edited February 2011
    As Mick suggests. Or make the result column part of the table
    SALES COMPUTED BY ....
  • edited 9:24AM
    Actually I have used a Dialog Box in my report. So I check my customers name which are sort asceding by surname and then I want them to be appeared in my masterdata field asceding by their investments. How can I create the temporary table?
  • edited 9:24AM
    Try this:

    1. OnDialogActivate create empty temp table
    2. OnBitBtnClik (when your user has filled the dialog box) fill the temp table with selected customers to be print
    3. Build the final query to use content of the temp table.

    This depends on your database - is it allows creating temp tables. If not then create standard table, and then OnDialogActivate delete rows from that table to make it ready for newly selected customers. If more than one user can print your report at the same time (which mean they all will use the SAME working table), add UserID to the temp table and delete only User's rows.

    You can manage filling the temp table with creating a query on-fly, eg.

    MyQry.SQL.Text := 'insert iD, CalcField into tempTab select s.Id, (s.qty * s.tax / s.no) from sales s where ' + MyWhereString
    MyQry.ExecSQL

    And MyWhereString will be created according to CustIds selected in the dialog.

    Mick
  • edited 9:24AM
    I made it like that and it worked! Thank you very much.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.