Skipping blank fields

Hi

I would like to be able to 'skip' fields if they are blank. For example if i have fields:

name
address1
address2
town
county
postcode

and some of my data is missing, for example, address2, i get:

Mr Smith
2 Queens Road

Morden
Surrey
SM4 5DF

What I would like is if town,county and postcode were 'moved up' to fill the blank space.

Is this possible and if so how would I do it?

I've searched through the manuals but I can find no refrence to this.

Thanks for the help

Pete

Comments

  • edited 8:13AM
    Make a trace steps:
    1) To create two Child Band's.
    2) On MasterData to place all Memo which go up to the first address switching him.
    3) To place the second address on Child1, and all rest on Child2.
    4) To establish properties MasterData. Child - Child1 and Child1. Child - Child2.
    5) In MasterData to include event OnBeforePrint and in him to write:
    procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
    begin
    if (<frxDBDataset1."Addr2"> = '') then {Database and Fields}
    begin
    MasterData1.child := Child2;
    Child1.Child := nil;
    end
    else
    if MasterData1.child = Child2 then
    begin
    MasterData1.child := Child1;
    Child1.child:= child2;
    end;
    end;
  • edited September 2005
    Hi

    Thanks for the reply, although I must admit I didnt understand it ;)

    I did solve the problem though by doing some processing and:

    creating a stringlist
    adding the data from my address fields to the string list:
    wrote:
    if (qryCDRequest.fieldbyname('ADDRESS1').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('ADDRESS1').asstring);
    if (qryCDRequest.fieldbyname('ADDRESS2').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('ADDRESS2').asstring);
    if (qryCDRequest.fieldbyname('ADDRESS3').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('ADDRESS3').asstring);
    if (qryCDRequest.fieldbyname('ADDRESS4').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('ADDRESS4').asstring);
    if (qryCDRequest.fieldbyname('TOWN').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('TOWN').asstring);
    if (qryCDRequest.fieldbyname('COUNTY').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('COUNTY').asstring);
    if (qryCDRequest.fieldbyname('COUNTRY').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('COUNTRY').asstring);
    if (qryCDRequest.fieldbyname('POSTCODE').asstring<>'') then
      address.Add(qryCDRequest.fieldbyname('POSTCODE').asstring);

    Then adding a memo with variables:
    wrote:
    [line1]
    [line2]
    [line3]
    [line4]
    [line5]
    [line6]
    [line7]
    [line8]

    Then assigning varables as normal:
    wrote:
    procedure Tadmin.frxReport1GetValue(const VarName: String;
      var Value: Variant);
    begin
      if CompareText(VarName, 'line1') = 0 then
      value:=address[0];
      if CompareText(VarName, 'line2') = 0 then
      value:=address[1];
        if CompareText(VarName, 'line3') = 0 then
      value:=address[2];
        if CompareText(VarName, 'line4') = 0 then
      value:=address[3];
        if CompareText(VarName, 'line5') = 0 then
      value:=address[4];
        if CompareText(VarName, 'line6') = 0 then
      value:=address[5];
        if CompareText(VarName, 'line7') = 0 then
      value:=address[6];
        if CompareText(VarName, 'line8') = 0 then
      value:=address[7];
    end;


    It doesnt seem a very elegant solution but it appears to work for me.

    Hope it helps someone else too

    Pete

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.