Ver Mensaje Individual
  #10  
Antiguo 12-03-2010
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Reputación: 25
Caral Va por buen camino
Hola
Sabiendo que la sentencia SQL es string se puede hacer casi cualquier cosa, un ejemplo:
Código Delphi [-]
procedure TForm3.BitBtn4Click(Sender: TObject);
var Texto: String;
begin
 Texto:= 'where clave = '+quotedstr(combobox1.Text)+' order by nombres asc';
 with datam.Query1 do begin;
 close;
 sql.Clear;

if radioButton1.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A1 from 20092'+Texto;
open;
edit;
end;

if radioButton2.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A2 from 20092'+Texto;
open;
edit;
end;

if radioButton3.Checked = true then
begin
sql.Text:='select NOMBRES,MATRICULA,CLAVE,A3 from 20092'+Texto;
open;
edit;
end;

if radioButton4.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A4 from 20092'+Texto;
open;
edit;
end;

if radioButton5.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A5 from 20092'+Texto;
open;
edit;
end;

if radioButton6.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A6 from 20092'+Texto;
open;
edit;
end;

if radioButton7.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A7 from 20092'+Texto;
open;
edit;
end;

if radioButton8.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A8 from 20092'+Texto;
open;
edit;
end;

if radioButton9.Checked = true then
begin
sql.Text:= 'select NOMBRES,MATRICULA,CLAVE,A9 from 20092'+Texto;
open;
edit;
end;

if radioButton10.Checked = true then
begin
sql.Text:= 'select NOMBRES, MATRICULA,CLAVE,A10 from 20092'+Texto;
open;
edit;
end;

end;
De esta manera no se repite el codigo constantemente.
Saludos
__________________
Siempre Novato
Responder Con Cita