Does anyone know how I can format a CPF / CNPJ in a report in strongs 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';
By removing the commented areas, I tried with Copy
, but without success, any ideas?
----- 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.000procedure 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';
00-99;1;_';
end;
Follow my QLac. Any ideas?
This is my code, but it gets messed up in some fields, that is, it follows the image:
I believe that by the format of the one to understand that it was wrong, but it is not in all, many are right, some idea of how to proceed?