Hola de nuevo Josep.
Me quedé pensando en que tal vez te resulte mas simple encapsular la acción en
F_Camions:
Código Delphi
[-]
...
type
TF_Camions = class(TForm)
...
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
public
class procedure Mostrar(aID: Integer);
end;
var
F_Camions: TF_Camions;
CodCam : Integer;
implementation
...
var
tmp : string;
CodCam : Integer;
class procedure TF_Camions.Mostrar(aID: Integer);
begin
tmp := F_ModulDades.Camions.SelectSQL.Text;
CodCam := aID;
if not Assigned(F_Camions) then
F_Camions := TF_Camions.Create(nil);
if not F_Camions.Visible then
F_Camions.Show;
F_Camions.BringToFront;
end;
procedure TF_Camions.FormShow(Sender: TObject);
begin
with F_ModulDades.Camions do
begin
Close;
SelectSQL.Text := 'SELECT * FROM BOM0001 WHERE ID = :PID';
ParamByName('PID').AsInteger := CodCam;
Open;
end;
end;
...
procedure TF_Camions.FormClose(Sender: TObject; var Action: TCloseAction);
begin
with F_ModulDades.Camions do
begin
Close;
SelectSQL.Text := tmp;
Open;
end;
Action:= caFree;
end;
procedure TF_Camions.FormDestroy(Sender: TObject);
begin
F_Camions := nil;
end;
Llamada desde
TF_Parcs:
Código Delphi
[-]
procedure TF_Parcs.JvDBGrid1DblClick(Sender: TObject);
begin
TF_Camions.Mostrar(Camions_ParcID.AsInteger);
...
end;
El problema de usar un solo IBDataSet, es que todos los componentes asociados a
Camions quedarán restringidos a la última consulta. En ese caso una solución es usar oto
TIBDataSet (o
TIBQuery) para realizar el posicionamiento en
F_Camiones.
Saludos.