procedure TfrmVentasConsulta.btnBuscarClick(Sender: TObject);
begin
dmDatos.cdsCliente.Active := false;
with dmDatos.qryListados do begin
Close;
SQL.Clear;
SQL.Add('SELECT caja, numero, fecha, hora, estatus, total-iva AS subtotal,');
SQL.Add('iva, total, cliente, clave FROM ventas v WHERE 1 = 1');
if(chkCliente.Checked) then
SQL.Add('AND cliente IN (SELECT clave FROM clientes WHERE nombre LIKE ''%' + txtClienteBusq.Text + '%'')');
if(chkFecha.Checked) then begin
SQL.Add('AND fecha >= ' + quotedstr(datetostr(FechaBusq.date)));
end;
Open;
end;
with dmDatos.cdsCliente do begin
Active := true;
txtRegistros.text := inttostr(dmDatos.cdsCliente.RecordCount);
FieldByName('caja').DisplayLabel := 'Caja';
FieldByName('caja').DisplayWidth := 4;
FieldByName('numero').DisplayLabel := 'Remisión';
FieldByName('numero').DisplayWidth := 8;
FieldByName('fecha').DisplayLabel := 'Fecha';
FieldByName('fecha').DisplayWidth := 9;
FieldByName('hora').DisplayLabel := 'Hora';
FieldByName('hora').DisplayWidth := 11;
FieldByName('estatus').DisplayLabel := 'Estatus';
FieldByName('estatus').DisplayWidth := 7;
FieldByName('subtotal').DisplayLabel := 'Subtotal';
FieldByName('subtotal').DisplayWidth := 10;
FieldByName('iva').DisplayLabel := 'IGV';
FieldByName('iva').DisplayWidth := 10;
FieldByName('total').DisplayLabel := 'Total';
FieldByName('total').DisplayWidth := 10;
FieldByName('cliente').Visible := false;
FieldByName('clave').Visible := False;
end;
if(pgeGeneral.ActivePage = tabBusqueda) then
grdListado.SetFocus;
end;
ese es todo el codigo
y en el stringgrid enlazo en el datasource el correspondiente datasource