Could not convert variant of type (Array Variant) into type (Integer)

hsmhsm
edited February 2018 in FastReport 4.0
I am trying to format a simple, single band tabular report showing people and their partners at run time.
My query returns strings in all fields (although some contain numbers). The query uses a dummy 'sortorder' field together with Unions that makes the query show the same data twice, the first half of the data sorted by the person's surname field and the second half by their partner's surname field. The two rows of dummy data in the 'member_title' field at the start and in the middle act as headings.

When these specific heading data rows are about to be printed I want to make the 'member_title' Memo change its font style, Left and Width so that it appears as a heading over all the columns of the report, with nothing else showing.

However the code in my report gives the error
Could not convert variant if type (Array Variant) into type (Integer)
when it hits those two lines.

If I comment out the code in the report it works fine and shows all the data, including the special lines (although of course with no special formatting etc.)

Can anyone see what is wrong with my code or the way I am doing it?

Below I have shown the relevant bits.

(BTW I realise that all the formatting should be done in report and that I shouldn't have the headings in the query but this seemed the easiest way to do it on this occasion)
Also the real name of the title memo is frxDBDatasetJointMemberCrossRefmember_title and of the report itself frxDBDatasetJointMemberCrossRef but I shortened the names here for clarity.

Sample data returned by the query

The code in the report
procedure Report1member_titleOnBeforePrint(Sender: TfrxComponent);
begin
        
if ( <Report1."member_title"> = 'Ordered by Member Surname')  OR
   ( <Report1."member_title"> ='Ordered by Joint Member Surname')    then
        begin
        MemoTitle.align := bawidth;
        MemoTitle.font.style := [fsbold, fsunderline];
        MemoTitle.left := 1; 
        MemoTitle.width := 17;        
        end            
else
        begin
        MemoTitle.align := banone;        
        MemoTitle.left := 2; 
        MemoTitle.width := 1;
        MemoTitle.font.style := 0;  //see https://www.fast-report.com/en/forum/index.php?showtopic=3846                       
        end;
end;


The report's layout


The SQL that gets the data

(
   SELECT
   'A*********' AS sortorder,
   '' AS member_id,
  'Ordered by Member Surname' AS member_title,
   '' AS member_fn,
   '' AS member_sn,
   '' AS joint_member_id,
   '' AS joint_member_title,
   '' AS joint_member_fn,
   '' AS joint_member_sn,
   '' AS surname_different 
  )

  UNION ALL

(
SELECT
     CONCAT('B',member.member_sn) AS sortorder,
     member.member_id AS member_id,
     IFNULL(member.member_title,'') AS member_title,

     CASE
       WHEN member.member_known_as IS NOT NULL THEN
          CONCAT(member.member_fn_1, ' (',member.member_known_as,')')
       ELSE
          member.member_fn_1
     END AS member_fn,
     member.member_sn AS member_sn,
     member_1.member_id AS joint_member_id,

     IFNULL(member_1.member_title,'') AS joint_member_title,

     CASE
       WHEN member_1.member_known_as IS NOT NULL THEN
          CONCAT(member_1.member_fn_1, ' (',member_1.member_known_as,')')
       ELSE
          member_1.member_fn_1
     END AS joint_member_fn,


     member_1.member_sn AS joint_member_sn,
     CASE WHEN member.member_sn <>  member_1.member_sn THEN '***' ELSE '' END AS surname_different


FROM
    joint_member
    INNER JOIN member
        ON (joint_member.base_member_id = member.member_id)
    INNER JOIN member AS member_1
        ON (joint_member.partner_member_id = member_1.member_id)


 ORDER BY     member.member_sn
 )

UNION ALL
   (SELECT 'C*********','','','','','','','','','' )

 UNION ALL
   (SELECT 'D*********','**********','**********','**********','**********','**********','**********','**********','**********','**********' )

 UNION ALL
   (SELECT 'E*********','','','','','','','','','' )
UNION ALL

 (SELECT
 'F*********' AS sortorder,
 '' AS member_id,
 'Ordered by Joint Member Surname' AS member_title,
 '' AS member_fn,
 '' AS member_sn,
 '' AS joint_member_id,
 '' AS joint_member_title,
 '' AS joint_member_fn,
 '' AS joint_member_sn,
 '' AS surname_different
)

UNION ALL

 (
SELECT 
   CONCAT('F',member.member_sn) AS sortorder,
     member_1.member_id AS member_id,
     IFNULL(member_1.member_title,'') AS member_title,
     
     CASE 
       WHEN member_1.member_known_as IS NOT NULL THEN 
          CONCAT(member_1.member_fn_1, ' (',member_1.member_known_as,')')
       ELSE 
          member_1.member_fn_1 
     END AS member_fn,

     member_1.member_sn AS member_sn,

     member.member_id AS joint_member_id,
     IFNULL(member.member_title,'') AS joint_member_title, 

     
     CASE 
       WHEN member.member_known_as IS NOT NULL THEN 
          CONCAT(member.member_fn_1, ' (',member.member_known_as,')')
       ELSE 
          member.member_fn_1 
     END AS joint_member_fn,
     
     member.member_sn AS joint_member_sn,
          CASE WHEN member.member_sn <>  member_1.member_sn THEN '***' ELSE '' END AS surname_different
     
  FROM
 joint_member
    INNER JOIN member 
        ON (joint_member.base_member_id = member.member_id)
    INNER JOIN member AS member_1
        ON (joint_member.partner_member_id = member_1.member_id)

 
 ORDER BY     member.jointmember_sn
 )
 ORDER BY sortorder

Comments

  • gpigpi
    edited 1:03PM
    Try MemoTitle.font.style := fsBold + fsUnderline;
  • hsmhsm
    edited 1:03PM
    gpi wrote: »
    Try MemoTitle.font.style := fsBold + fsUnderline;

    That did it, thanks

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.