procedure TKundenDruckMenue.Button6Click(Sender: TObject);
var
cSql : String;
begin
with ADOQuery1 do begin
Active := False;
Sql.Clear;
if CheckBox1.Checked then begin
cSql := 'Select DISTINCT KundenNr, Anrede, Titel, Vorname, Nachname, Straße, PLZ, Ort, Geburtsdatum, Land, Beruf, Telefon, Mobil, Fax, email FROM Kundendaten';
end else
if (allekunden.Checked = False) and (email.Checked = False) and (lv.Checked = False) and (flv.Checked = False) and (
df.Checked = False) and (ff.Checked = False) and (sv.Checked = False) and (bsp.Checked = False) and (sto.Checked = False) and (mk.Checked = False) then
begin
if Trim(Edit1.Text) = '' then begin
ShowMessage('Bitte geben Sie einen Wert ein!');
exit;
end;
cSql := 'Select DISTINCT KundenNr, Anrede, Titel, Vorname, Nachname, Straße, PLZ, Ort, Geburtsdatum, Land, Beruf, Telefon, Mobil, Fax, email FROM Kundendaten where (' + ComboBox1.Text + ' like ' + QuotedStr (Edit1.Text + '%') +')'
end
else
cSql := 'Select DISTINCT A.KundenNr, A.Anrede, A.Titel, A.Vorname, A.Nachname, A.Straße, A.PLZ, A.Ort, A.Geburtsdatum, A.Land, A.Beruf, A.Telefon, A.Mobil, A.Fax, A.email FROM Kundendaten A LEFT JOIN Geschaeftsdaten B ON A.KundenNr = B.KundenNr ';
if (allekunden.Checked) and (flv.Checked) and (lv.Checked) and (
df.Checked) and (ff.Checked) and (sv.Checked) and (bsp.Checked) and (sto.Checked) then
cSql := cSql + ' AND ( [A.ist Kunde] = True OR [B.flv] = True OR [B.lv] = True OR [B.df] = True OR [B.ff] = True OR [B.sv] = True OR [B.bsp] = True OR [B.sto] = True OR [A.email] = True OR [B.eigengeschaeft] = True)'
else if allekunden.Checked then
cSql := cSql + ' WHERE A.[ist Kunde] = True'
else if flv.Checked then
cSql := cSql + ' WHERE B.[flv] = True'
else if lv.Checked then
cSql := cSql + ' WHERE B.[lv] = True'
else if
df.Checked then
cSql := cSql + ' WHERE B.[
df] = True'
else if ff.Checked then
cSql := cSql + ' WHERE B.[ff] = True'
else if sv.Checked then
cSql := cSql + ' WHERE B.[sv] = True'
else if bsp.Checked then
cSql := cSql + ' WHERE B.[bsp] = True'
else if sto.Checked then
cSql := cSql + ' WHERE B.[sto] = True'
else if mk.Checked then
cSql := cSql + ' WHERE B.[eigengeschaeft] = True';
if email.Checked then
cSql := cSql + ' WHERE TRIM (A.[email]) <> ' + QuotedStr ('');
Sql.Add(cSql);
Open;
end;
end;