Recent

Author Topic: Hiding a specific field in LAZREPORT  (Read 2902 times)

GKRAFT63

  • New Member
  • *
  • Posts: 16
Hiding a specific field in LAZREPORT
« on: September 10, 2015, 02:41:51 am »
I have a simple address book sqlite3 table named ADDRESSBK.  It has the basic fields Name, address, phone, etc.  I also have a field named "Publish" which can be (Y)es or (N)o. Just Y or N.   When making a report if this field is "N" how would I go about hiding some other fields on that same line like Phone or Address? Would I use a script, and if so what is the correct format.  I tried something like this but it doesn't work:

If [SQLQuery1."PUBLISH"] = 'Y' then [SQLQuery1."ADDRESS"] := '';

Thanks,
Greg
« Last Edit: September 10, 2015, 02:56:13 am by GKRAFT63 »

bylaardt

  • Sr. Member
  • ****
  • Posts: 304
Re: Hiding a specific field in LAZREPORT
« Reply #1 on: September 10, 2015, 04:06:58 am »
In your select statement use case condicionals.
more information on SQLite Manual (or any SQL ansi-92 compatible DBMS)

GKRAFT63

  • New Member
  • *
  • Posts: 16
Re: Hiding a specific field in LAZREPORT
« Reply #2 on: September 10, 2015, 04:17:09 am »
So what your saying is do it via the SQL statement.... thanks I'll look into it.

GKRAFT63

  • New Member
  • *
  • Posts: 16
Re: Hiding a specific field in LAZREPORT
« Reply #3 on: September 10, 2015, 04:47:37 am »
I looked at sql conditionals but didn't find anyway of including some values of a record, and excluding others. In other words displaying First name last name but hiding the phone number?

jesusr

  • Sr. Member
  • ****
  • Posts: 470
Re: Hiding a specific field in LAZREPORT
« Reply #4 on: September 10, 2015, 05:59:46 am »
In your report you have associated memo objects to a field values, for example, Memo1 displays [SQLQuery1."PUBLISH"] and memo2 displays [SQLQuery1."ADDRESS"].

One way of doing what you want is using the TfrReport OnEnterRect event, in the handler of that event you may want to do something like this:
Code: [Select]
var
  haveToHide: boolean;
begin
  haveToHide := SQLQuery1.FieldByName('PUBLISH').asString='Y';
  if haveToHide and (View.Name='Memo2') then TfrMemoView(View).Memo.Text := '';
  ...
end;
Note that View.Name is being checked literally.

GKRAFT63

  • New Member
  • *
  • Posts: 16
Re: Hiding a specific field in LAZREPORT
« Reply #5 on: September 10, 2015, 02:32:24 pm »
That worked beautiful!! Thanks a bunch!