Could not convert variant if type (Array Variant) into type (OleStr)

edited October 2016 in FastReport VCL 5
Hi

I am currently getting the following error message "Could not convert variant if type (Array Variant) into type (OleStr)" while trying to execute the following code within a Memo:

[([IIF(<frxDBDataset2."MEM_ID"> = '',VarToStr(<frxDBDataset2."DEP_PASSPORT">),VarToStr(<frxDBDataset2."MEM_ID">))])]

I am trying to create a MasterDetail report, where in the Detail, the memo needs to see if the current record has an ID Number, if they do, it must print the ID Number, if not, it must print a Passport Number for me.

There is no documentation or any examples in the User's Manual, Developer Manual, or Programmers Manual on how to use any of the functions within FR5 VCL and the explanations at the bottom of the Expression Editor is sometimes very vague.

Can someone please help and explain what I need to do and change to make this work?

Using Delphi 10 Seattle with FastReports5 VCL Embarcadero Edition.

Thanks.

Comments

  • gpigpi
    edited 2:01PM
    Try
    [IIF(<frxDBDataset2."MEM_ID"> = '', VarToStr(<frxDBDataset2."DEP_PASSPORT">), VarToStr(<frxDBDataset2."MEM_ID">))]
  • edited October 2016
    gpi wrote: »
    Try
    [IIF(<frxDBDataset2."MEM_ID"> = '', VarToStr(<frxDBDataset2."DEP_PASSPORT">), VarToStr(<frxDBDataset2."MEM_ID">))]

    Thank you very much, that worked perfectly. But i see it is exactly the same as my code, except mine has 2 extra brackets at the beginning and end, so why didn't mine work?

    How do I use this code for Dates?

    [IIF(<frxDBDataset2."MEM_DATERESIGNED"> = '', VarToStr('Current'), VarToStr(<frxDBDataset2."MEM_DATERESIGNED">))]

    As I get this error message: "Could not convert variant if type (UnicodeString) into type (Double)"
  • gpigpi
    edited 2:01PM
    wrote:
    except mine has 2 extra brackets at the beginning and end, so why didn't mine work?
    So don't use 2 extra brackets
    wrote:
    How do I use this code for Dates?
    Your code should works for dates. If you use text (not date) formatting in the TfrxMemoView
  • edited 2:01PM
    gpi wrote: »
    gpi wrote: »
    except mine has 2 extra brackets at the beginning and end, so why didn't mine work?
    So don't use 2 extra brackets
    gpi wrote: »
    How do I use this code for Dates?
    Your code should works for dates. If you use text (not date) formatting in the TfrxMemoView

    Thank you very much, just forgot to use TO_CHAR in my query for my dates and convert it to a string value.

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.