Autor Beitrag
wolle-
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Fr 06.05.05 13:40 
Schönen Guten Tag, ich habe alles so wie ich es möchte ein Programm, wo ich neue Daten eintragen kann, ändern kann oder löschen kann!

Nun habe ich 3 Felder : Tag - Monat - Jahr
2 2 4

Nun habe ich vor eine Such funktion einzubauen also wenn ich nun in die suchmaske 03 eingebe (Soll nur für Monat gelten), Sollte er mir in meiner Auflistung alle Personen anzeigen bei denen ich 03 als Monat angegeben habe.

Ist sowas realisierbar? Ich hab schon so viel probiert.

Ich danke sehr

mfg wolle

_________________
Don`t eat yellow snow ;)!!
Jailbird
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 127

Windows XP Pro SP2
Delphi 7 Professional
BeitragVerfasst: Fr 06.05.05 14:02 
Sicher ist das realisierbar. Allerdings weiss ich nicht, was für eine Datenbank du verwendest
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Fr 06.05.05 14:04 
Paradox 7! :)

Habe das grade so versucht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.Button1Click(Sender: TObject);
var id : variant;
i : integer;
begin
  query1.sql.clear;
  query1.SQL.Add ('select * from adressen.DB where Monat like ' + quotedstr('%' + edit1.text + '%') + ' ;');
  query1.open ;
  if query1.recordcount <> 0 then begin
    id := query1.FieldValues['Monat'];
    query1.close;
    query1.sql.clear;
    query1.SQL.Add ('select * from adressen.DB ;');
    query1.open ;
    for i := 0 to  query1.RecordCount - 1 do begin
      if query1.FieldValues['Monat'] = id then begin
         thack(Dbgrid1).DataLink.ActiveRecord := i;
         dbgrid2.Repaint;
         query1.close;
         exit;
      end;
      query1.next;
    end;
  end;
  query1.close;
end;


Also das funktioniert, aber der zeigt nich nur alle die 03 sind sondern macht nur den Pfeil vor den ersten mit 03, verstehst du,
alle die nicht 03 haben sollen ausgeblendet werden! Danke :)

_________________
Don`t eat yellow snow ;)!!
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Fr 06.05.05 14:24 
Achja noch nebenbei? Wie mache ich das, wenn ich das programm auf einem PC ohne Delphi laufen lassen will?! Wegen Datenbank, das muss doch funktionieren!

Muss ich dann bei ihm:

BDE 5.2 MSI Merge Module German Enterprise version (9,683,069 bytes

Installieren? :)

_________________
Don`t eat yellow snow ;)!!
Jailbird
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 127

Windows XP Pro SP2
Delphi 7 Professional
BeitragVerfasst: Fr 06.05.05 15:24 
naja...ist also 'ne SQL-fähige Datenbank. Was für 'nen Typ hat denn das Datenbankfeld Monat?
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Sa 07.05.05 12:39 
A ist der TYP

_________________
Don`t eat yellow snow ;)!!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 07.05.05 13:10 
Hallo,
user profile iconwolle- hat folgendes geschrieben:
Achja noch nebenbei? Wie mache ich das, wenn ich das programm auf einem PC ohne Delphi laufen lassen will?! Wegen Datenbank, das muss doch funktionieren!

nur so nebenbei, für neue Fragen müssen in diesem Forum neue Topics mit entsprechend aussagekräftigen Titel erstellt werden. Aber gerade zu diesem Problem solltest du unzählige Antworten hier im Forum finden können, wenn du z.B. nach Suche in: Delphi-Forum, Delphi-Library PARADOX INSTALLIEREN suchst.

Gruß
Klabautermann


Zuletzt bearbeitet von Klabautermann am Sa 07.05.05 13:14, insgesamt 2-mal bearbeitet
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Sa 07.05.05 13:11 
Danke

_________________
Don`t eat yellow snow ;)!!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 07.05.05 13:14 
Hi,

da muss ich meinen Edit doch zu einem neuen Topic machen ;).

Also zur Frage: Ich nehme an, dass du dein DataGrid an ein tTable Objekt angeschlossen hast. In diesem (leicht angestaubten) Tutorial wird unter anderen auch erklährt, wie die die Filter Eigenschaft bei diesem benutzen kannst, diese könnte dir helfen.
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Sa 07.05.05 14:05 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
begin

  table1.Filtered := FALSE;
  table1.Filter := 'Monat'= Edit1.Text;
  table1.Filtered := TRUE;

end;


und wieso funzt das nicht? :(

Edit*

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
begin
 Edit1.Text := table1.FieldByName('Monat').AsString;
  table1.Filtered := FALSE;
//  table1.Filter := 'Monat=''Edit1.Text''';
 Edit1.Text := table1.Filter := 'Monat';
  table1.Filtered := TRUE;

end;


will auch nicht aber scheibe ich


ausblenden Delphi-Quelltext
1:
  table1.Filter := 'Monat=''03''';					


Dann funzt es

_________________
Don`t eat yellow snow ;)!!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 07.05.05 15:12 
user profile iconwolle- hat folgendes geschrieben:

und wieso funzt das nicht? :(

Edit*

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
begin
 Edit1.Text := table1.FieldByName('Monat').AsString;
  table1.Filtered := FALSE;
//  table1.Filter := 'Monat=''Edit1.Text''';
 Edit1.Text := table1.Filter := 'Monat';
  table1.Filtered := TRUE;

end;


will auch nicht aber scheibe ich


ausblenden Delphi-Quelltext
1:
  table1.Filter := 'Monat=''03''';					


Dann funzt es

Mal abgesehen von zahlreichen verstößen gegen die Delphi Syntax (zum zusammensetzen der Strings verwendest du am besten den + Operator zwei := tauchen niemals in der selben Zeile auf usw.) wird das an den Anfürungsstrichen Liegen, da du in der Datenbank Monat als Alphanumerisch, also String defeniert hast, musst du es in Anführungszeichen setzen. Das sähe also so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
begin
  table1.Filtered := FALSE;
  table1.Filter := 'Monat=''' + table1.FieldByName('Monat').AsString + '''';
  table1.Filtered := TRUE;
end;


Zwei aufeinanderfolgende einzelne Anführungszeichen in einem String ergeben im Ergebnis eines.

Da dieses leicht zu verwirrungen führt kannst du auch die Funktion QuotedStr verwenden um die Anführungszeichen ein zu fügen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
begin
  table1.Filtered := FALSE;
  table1.Filter := 'Monat=' + QuotedStr(table1.FieldByName('Monat').AsString);
  table1.Filtered := TRUE;
end;


Gruß
Klabautermann
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Sa 07.05.05 15:16 
Da ist doch nirgendswo mein Edit1.Text? hä?

_________________
Don`t eat yellow snow ;)!!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Sa 07.05.05 16:20 
Hallo,
user profile iconwolle- hat folgendes geschrieben:
Da ist doch nirgendswo mein Edit1.Text? hä?

du machst folgende Zuweisung: Edit1.Text := table1.FieldByName('Monat').AsString; und willst dann später den Wert wieder verwenden (table1.Filter := 'Monat=''Edit1.Text''';) das die Zeile "Edit1.Text := table1.Filter := 'Monat';" keinen Sinn macht habe ich sie ignoriert.
Da du Edit1 zu nichts anderen verwendest als als Behälter von table1.FieldByName('Monat').AsString habe ich es Wegoptmiert und diereckt die Zeile: table1.Filter := 'Monat=' + QuotedStr(table1.FieldByName('Monat').AsString); daraus gebaut.

Wenn du willst, dass der user eine Zahl eingeben kann, dann tausche meine Ergebniszeile gegen diese aus:
ausblenden Delphi-Quelltext
1:
table1.Filter := 'Monat=' + QuotedStr(Edit1.Text);					


Gruß
Klabautermann
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: Sa 07.05.05 17:00 
Dankeschön, werde ich direkt ausprobieren! :D

_________________
Don`t eat yellow snow ;)!!
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: So 08.05.05 09:18 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var
lol : String;
begin
lol := Combobox1.Text;
table1.Filtered := FALSE;
table1.Filter := lol = + QuotedStr(Edit1.Text);
 table1.Filtered := TRUE;


Das müsste doch demnach dann auch funktionieren oder?
Das was ich in der Combobox angewählt habe nimmt er?!

_________________
Don`t eat yellow snow ;)!!
feuerwaran
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 08.05.05 09:54 
user profile iconwolle- hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
var
lol : String;
begin
lol := Combobox1.Text;
table1.Filtered := FALSE;
table1.Filter := lol = + QuotedStr(Edit1.Text);
 table1.Filtered := TRUE;


Das müsste doch demnach dann auch funktionieren oder?
Das was ich in der Combobox angewählt habe nimmt er?!


Mach doch mal den = Operator weg. Dann funktioniert es. Außer du meintest den =+ operator, aber den gibts leider nur unter c. :D
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: So 08.05.05 10:29 
Danke, leider funktioniert das immernoch nicht, wähle ich nun in der Combobox eine Suchoption an z.B. Nachname ... und schreibe Peters dann kommt

Zitat:
---------------------------
Morph - Kundendarten
---------------------------
Filterausdruck fehlerhaft abgeschlossen.
---------------------------
OK
---------------------------



FÜR ALLE DIE DIE ANTWORT SUCHEN:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
lol : String;
begin
lol := Combobox1.text;
table1.Filtered := FALSE;
table1.Filter := lol + '=' + QuotedStr(Edit1.Text);
table1.Filtered := TRUE;
end;

_________________
Don`t eat yellow snow ;)!!
feuerwaran
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 08.05.05 21:19 
user profile iconwolle- hat folgendes geschrieben:
Danke, leider funktioniert das immernoch nicht, wähle ich nun in der Combobox eine Suchoption an z.B. Nachname ... und schreibe Peters dann kommt

Zitat:
---------------------------
Morph - Kundendarten
---------------------------
Filterausdruck fehlerhaft abgeschlossen.
---------------------------
OK
---------------------------



FÜR ALLE DIE DIE ANTWORT SUCHEN:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
lol : String;
begin
lol := Combobox1.text;
table1.Filtered := FALSE;
table1.Filter := lol + '=' + QuotedStr(Edit1.Text);
table1.Filtered := TRUE;
end;


Versuch mal

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
lol : String;
begin
lol := Combobox1.text;
table1.Filtered := FALSE;
table1.Filter := lol + ' = ' + QuotedStr(Edit1.Text);
table1.Filtered := TRUE;
end;


Also diese Leerzeichen beim = einfügen. Ich meine so steht es in der Online-Hilfe. Vielleicht nimmt es Delphi hier sehr genau.
wolle- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 128

XP Prof, Suse 9.2
D7
BeitragVerfasst: So 08.05.05 21:25 
Oerm es hat nun auch ohne funktioniert

ausblenden Delphi-Quelltext
1:
'='					


Danke leute, kann man vielleicht dieses Casesensitive beim suchen ausmachen?

_________________
Don`t eat yellow snow ;)!!
feuerwaran
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: So 08.05.05 21:48 
TBDEDataSet.FilterOptions .... schau mal in der Online-Hilfe genauer nach.