0
Does anyone know how to format a CPF/CNPJ in a report in the Forte Report?
procedure TFRelMenLac.RLBand4BeforePrint(Sender: TObject; var PrintIt: Boolean);
var
ltemp : string;
begin
ltemp := dmretaguarda.qlac.fieldbyname('dccli').asstring;
if length(ltemp) = 11 then
begin
rlldccli.Caption := 'CPF: ';
//RLDBText29.DisplayMask := '000.000.000-00';
RLDBText29.Text := copy(ltemp, 1,3)+'.'+copy(ltemp, 4,3)+'.'+copy(ltemp, 7,3)+'-'+copy(ltemp, 10,2);
end
else
begin
rlldccli.Caption := 'CNPJ: ';
RLDBText29.Text := copy(ltemp, 1,3)+'.'+copy(ltemp, 4,3)+'.'+copy(ltemp,7,3)+'/'+copy(ltemp, 10,4)+'-'+copy(ltemp, 14,2);
end;
//RLDBText29.DisplayMask := '000.000.000/0000-00';
Aside from the commented areas, I tried with the Copy
, but unsuccessfully, some idea?
----- Edit -----
DMRetaguarda.QLac.close;
DMRetaguarda.QLac.sql.clear;
DMRetaguarda.QLac.SQL.Add('SELECT relinm.mattec, relinm.nmtec, relinm.nmequip, relinm.num_os, relinm.num_sel, relinm.dtpront, relinm.marca, relinm.modelo, relinm.matric, relinm.peso, relinm.num_lac, relinm.numinm,');
DMRetaguarda.QLac.SQL.Add('cliente.razaosocial, cliente.cidade as clcid, cliente.uf as cluf, cliente.rua as clru, cliente.bairro as clbr, cliente.cep as clcp, cliente.chave, CASE WHEN cliente.cgc <> '''' THEN cliente.cgc ELSE cliente.cpf END AS dccli ');
DMRetaguarda.QLac.SQL.Add('FROM relinm, cliente WHERE relinm.codcli = cliente.chave AND relinm.dtpront BETWEEN :pini AND :pfim ORDER BY relinm.mattec, relinm.nmequip, relinm.dtpront');
DMRetaguarda.QLac.ParamByName('pini').AsDate := StrToDateTime(
MaskEdit1.Text);
DMRetaguarda.QLac.ParamByName('pfim').AsDate := StrToDateTime(
MaskEdit2.Text);
DMRetaguarda.QLac.open;
---- Edit2 ----
if length(DMRetaguarda.QLac.FieldByName('dccli').AsString) = 11 then
begin
rlldccli.Caption := 'CPF: ';
DMRetaguarda.QLac.FieldByName('dccli').EditMask := '999.999.999-99;0;_'
//RLDBText29.DisplayMask := '000.000.000\-99;1;_';
//RLDBText29.Text := copy(ltemp, 1,3)+'.'+copy(ltemp, 4,3)+'.'+copy(ltemp, 7,3)+'-'+copy(ltemp, 10,2);
end
else
begin
rlldccli.Caption := 'CNPJ: ';
DMRetaguarda.QLac.FieldByName('dccli').EditMask := '99.999.999/9999-99;0;_';
//RLDBText29.Text := copy(ltemp, 1,3)+'.'+copy(ltemp, 4,3)+'.'+copy(ltemp,7,3)+'/'+copy(ltemp, 10,4)+'-'+copy(ltemp, 14,2);
//RLDBText29.DisplayMask := '000.000.000\0000-99;1;_';
end;
Follow my Qlac. Any ideas?
It was like this my code but is all scrambled in some fields, IE, follows the image:
I believe that by the format of to understand that it was wrong, however it is not at all, many are right, some idea of how to proceed?
Anyone? Any ideas? @Caputo
– Ramon Ruan
@Filipe.Fonseca, some idea?
– Ramon Ruan
You can implement this in Tfield’s Gettext or Set the Mask to Tfield, have tried?
– Caputo
@Caputo, I tried not dude :/, there’s some example of how I would do it?
– Ramon Ruan
Please add in the question the snippet where the query
dtmretaguarda.qlac
is open to report generation and the report is executed. I set the example right where it should be.– Caputo
@Caputo, sorry for the delay, I was sick, I will post as soon as possible. Thanks
– Ramon Ruan
@Caputo, follow my query. Thanks, I await return.
– Ramon Ruan
What Query component you are using?
– wesley luan
@wesleyluan, Tzquery, ZEOS component.
– Ramon Ruan
@wesleyluan, put the image and the code after edited.
– Ramon Ruan
When you change the field mask which is CPF the size of it is no longer 11, the field will have dots and dash.
– wesley luan