[Reports] Checkbox how to

More
1 year 8 months ago - 1 year 8 months ago #24474 by prashant
Hi,
Back with more question on reports


I have a BIT field in SQL which I am able to view in Report Module as 1/0 or True/False using the inbuilt formatting . See example.
 

I am uanble to figure how to use the checkbox object to show the item as a checkbox , whenever I mess with settings of checkbox I get blank item

1. I have tried mapping the item in settings . See example 
 
2. I have tried using script made by chatgpt , but no avail

Script
procedure CheckBox1OnBeforePrint(Sender: TfrxComponent);
begin    
    CheckBox1.Checked := <ADOQuery1."imp"> = True;
end;  

begin
end.

procedure CheckBox1OnBeforePrint(Sender: TfrxComponent);
begin
  if <ADOQuery1."imp"> = 1 then
    CheckBox1.Checked := True
  else
    CheckBox1.Checked := False;
end;  

begin
end.      
 
Last edit: 1 year 8 months ago by prashant.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago - 1 year 8 months ago #24476 by admin
Replied by admin on topic [Reports] Checkbox how to
imp field has bit type and not integer

You are comparing bit to integer
try converting it first

CAST(imp AS int) AS Int_Column

This one works absolutely fine

procedure CheckBox1OnBeforePrint(Sender: TfrxComponent);
begin
  if <ADOQuery."UnitPrice">>12 then CheckBox1.Checked:=true
  else CheckBox1.Checked:=false 
end;

Mike
ETL Architect
Last edit: 1 year 8 months ago by admin.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #24479 by prashant
Replied by prashant on topic [Reports] Checkbox how to
HI Mike,

I converted to integer, Thank you I was able to get this to work with your code. 

I was also able to get the result from using Expression . See below

 
 

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #24481 by prashant
Replied by prashant on topic [Reports] Checkbox how to
OK another finding , even if the value is 'BIT'

I am able to use the expression field with <ADOQuery1."imp">='True' and it's working with code as well

procedure CheckBox1OnBeforePrint(Sender: TfrxComponent);
begin  
if <ADOQuery1."imp">='True' then    
CheckBox1.Checked := True  
else    
CheckBox1.Checked := False;
end;    

begin end.
The following user(s) said Thank You: Peter.Jonson

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save