Ver Mensaje Individual
  #7  
Antiguo 14-05-2011
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.

Modifique los nombres de campos en las tablas que utilicé en la prueba por los que pusiste en tu mensaje.

Esta consulta funciona correctamente:
Código Delphi [-]
procedure TForm1.FiltrarComboBox;
begin
  IBQuery1.Close;
  IBQuery1.SQL.Clear;
  IBQuery1.SQL.Add('SELECT C1.NOMBRE FROM UNIDADES C1, CATEGORIAS C2');
  IBQuery1.SQL.Add('WHERE NOMBRE2 = CCATEGORIAS AND NOMBRE2 =');
  IBQuery1.SQL.Add('(SELECT CCATEGORIAS FROM CATEGORIAS C2 WHERE C2.NOMBRE =:NOMB)');
  IBQuery1.ParamByName('NOMB').AsString:= cbCategorias.Text;
  IBQuery1.Open;
  cbUnidades.Clear;
  while not IBQuery1.Eof do
  begin
    cbUnidades.Items.Add(IBQuery1.FieldByName('NOMBRE').AsString);
    IBQuery1.Next;
  end;
  cbUnidades.ItemIndex:= 0;
  IBQuery1.Close
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  IBQuery1.Close;
  IBQuery1.SQL.Text:= 'SELECT * FROM CATEGORIAS ORDER BY NOMBRE';
  IBQuery1.Open;
  while not IBQuery1.Eof do
  begin
    cbCategorias.Items.Add(IBQuery1.FieldByName('NOMBRE').AsString);
    IBQuery1.Next;
  end;
  cbCategorias.ItemIndex:= 0;
  IBQuery1.Close;
  IBQuery1.SQL.Text:= 'SELECT * FROM UNIDADES ORDER BY NOMBRE';
  IBQuery1.Open;
  while not IBQuery1.Eof do
  begin
    cbUnidades.Items.Add(IBQuery1.FieldByName('NOMBRE').AsString);
    IBQuery1.Next;
  end;
  cbUnidades.ItemIndex:= 0;
  IBQuery1.Close;
  FiltrarComboBox
end;

procedure TForm1.cbCategoriasChange(Sender: TObject);
begin
  FiltrarComboBox
end;

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita