Autor Beitrag
jann
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Do 11.09.03 11:34 
Hi

ich habe folgendes problem. Ich will aus einer Access Datenbank filtern.
Der Filterausdruck soll eine and und or abfragen enthalten
ich habe es so versucht zu lösen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
i :=Form1.Edit1.Text;
x :=Form1.Edit2.Text;
Form1.ADOTable1.Filter :='PRTAUJAHR <='+i+' or PRTIU1RJA <='+i+'
and PRTBEZUSMO <= '
+x;


Die Edit Felder laufen mit dem Ereigniss EditKeyUp, wenn ich im programm etwas in die felder eingeben will kommt die Fehlermeldung:

Die Argumente sind vom Falschen Typ, liegen außerhalb des Gültigkeitsbereichs oder sind miteiander Unvereinbar

wenn ich nur die or abfrage mache habe ich keinen fehler

danke schonmal!

Moderiert von user profile iconUGrohne: Delphi-Tags eingefügt
biohazard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Do 11.09.03 13:27 
Hallo,

ich weiß jetzt nicht ob du das schon versucht hast. Wenn nicht versuch mal die OR anweisungen in Klammern zu setzen.

ausblenden Quelltext
1:
2:
Form1.ADOTable1.Filter :='(PRTAUJAHR <='+i+' or PRTIU1RJA <='+i+') 
and PRTBEZUSMO <= '+x;


ansonsten würde ich noch mal prüfen ob du nicht noch irgendwelche Zeichen setzen mußt, z.B. extra Hochkommas beim String

_________________
LIVE FAST, DIE YOUNG
jann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Do 11.09.03 13:34 
Hat leider nicht geklappt. Der fehler kommt immer noch. Mit den hochkommas müsste alles in ordnung sein, denn ohne die and abfrage funktioniert es.
jann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Do 11.09.03 13:51 
Hab grad nochmal was aus Probiert. Das Problem muss mit der zweiten Variable zusammen hängen, denn wenn alles mit einer Variablen gemacht wird funktionirt es.
Wie kann ich da eine zweite variable einbinden????
Ist EditKeyUp villeicht das Falsche Ereigniss für die Edit Felder?
biohazard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Do 11.09.03 14:04 
Eigentlich muß es auch mit zwei variablen gehen.
Welchen Datentypen haben das Feld PRTBEZUSMO und die variable x eigentlich? Kann sein das da was nicht hinhaut.

Mit dem EditKeyUp kommt es darauf an was du eingibst, da ja bei jedem loslassen der Taste das Ereignis ausgelöst wird.
Evtl. würde ich es mal mit OnExit versuchen.

_________________
LIVE FAST, DIE YOUNG
jann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Do 11.09.03 14:29 
Die beiden Variablen sind string Variablen die Felder sind ebenfals string. Mit der Zweiten Variablen kommt der Rechner immer noch nicht klar.

Ich will in die Felder jahreszahlen eingeben (z.b. 1999).
biohazard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Do 11.09.03 14:50 
Das einzige was ich jetzt noch versuchen würde ist: QuotedStr
Also wo du X stehen hast QuotedStr(x) einsetzen.

Form1.ADOTable1.Filter :='PRTAUJAHR <='+i+' or PRTIU1RJA <='+i+'
and PRTBEZUSMO <= '+QuotedStr(x);

_________________
LIVE FAST, DIE YOUNG
jann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Do 11.09.03 15:25 
Danke erstmal die zweite Variable nimmt er an.
Hab jetzt nur noch ein Problem mit dem and hat doch nicht funktioniert. Wen ich
Form1.ADOTable1.Filter :='PRTAUJAHR <='+i+' and PRTBEZUSMO <= '+QuotedStr(x);
nehme funktioniert alles, aber wenn noch ein or dazukommt gibts wieder nen fehler.
kann sein das ich da falsch klammere:

Form1.ADOTable1.Filter :='(PRTAUJAHR <='+i+' or PRTIU1RJA <='+i+')
and PRTBEZUSMO <= '+QuotedStr(x);
biohazard
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 89



BeitragVerfasst: Do 11.09.03 15:44 
Hab eigentlich auch gedacht das es richtig geklammert ist.
Das sieht jetzt ein wenig komisch aus aber was ist wenn du es mal so probierst:

ausblenden Quelltext
1:
Form1.ADOTable1.Filter :='(PRTAUJAHR <='+i+' and PRTBEZUSMO <= '+QuotedStr(x) +') or (PRTIU1RJA <='+i+' and PRTBEZUSMO <= '+QuotedStr(x)+')';					


Entweder die erste Möglichkeit herausfiltern ansonsten die zweite.

Schau dir den Text besser noch mal an, ich weiß jetzt nicht ob ich alle Zeichen richtig gesetzt habe. Die Variable i könnte man zu Not auch noch in QuotedStr setzen.

_________________
LIVE FAST, DIE YOUNG
jann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35



BeitragVerfasst: Fr 12.09.03 08:35 
Danke jetzt klappt alles