Ver Mensaje Individual
  #9  
Antiguo 28-10-2010
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Rofocale.

No pusiste la estructura de los datos, así que voy a tratar de inferir ...
Supongamos que declaraste:
Código SQL [-]
CREATE DOMAIN IN_AB CHAR(1) CHECK(VALUE IN('A','B')) NOT NULL;
CREATE DOMAIN VARCHAR20 VARCHAR(20) NOT NULL;

CREATE TABLE TBCATEGORIAS(
  Categoria IN_AB,
  Nombre VARCHAR20
);

CREATE TABLE TBUNIDADES(
  Categoria IN_AB,
  Nombre VARCHAR20
);

Y tenes ingresado:
TBCATEGORIAS
------------
A BEBIDAS
B LICORES

TBUNIDADES
----------
A GASEOSAS
A JUGOS
B VINOS
B LICORES
A LICUADOS
B AGUARDIENTES

Siendo cbCategorias y cbUnidades de tipo TComboBox, una forma de hacerlo puede ser:
Código Delphi [-]
procedure TForm1.FiltrarComboBox;
begin
  with IBQuery1 do
  begin
    Close;
    SQL.Text:= 'SELECT CATEGORIA, NOMBRE FROM TBCATEGORIAS C1, TBUNIDADES C2 '+
     'WHERE (C1.CATEGORIA = C2.CATEGORIA) AND '+
     'C2.CATEGORIA = (SELECT CATEGORIA FROM TBCATEGORIAS WHERE NOMBRE = '+
     QuotedStr(cbCategorias.Text)+')';
    Open;
    cbUnidades.Clear;
    while not Eof do
    begin
      cbUnidades.Items.Add(FieldByName('NOMBRE').AsString);
      Next;
    end;
    cbUnidades.ItemIndex:= 0;
    Close
  end;
end;

Código Delphi [-]
procedure TForm1.FormShow(Sender: TObject);
begin
 with IBQuery1 do
  begin
    Close;
    SQL.Text:= 'SELECT * FROM TBCATEGORIAS ORDER BY NOMBRE';
    Open;
    while not Eof do
    begin
      cbCategorias.Items.Add(FieldByName('NOMBRE').AsString);
      Next;
    end;
    cbCategorias.ItemIndex:= 0;
    Close;
    SQL.Text:= 'SELECT * FROM TBUNIDADES ORDER BY NOMBRE';
    Open;
    while not Eof do
    begin
      cbUnidades.Items.Add(FieldByName('NOMBRE').AsString);
      Next;
    end;
    cbUnidades.ItemIndex:= 0;
    Close;
  end;
  FiltrarComboBox
end;

Código Delphi [-]
procedure TForm1.cbCategoriasChange(Sender: TObject);
begin
  FiltrarComboBox;
end;

Saludos.
Responder Con Cita