16. december 2001 - 20:53Der er
1 kommentar og 1 løsning
Table1.Filter - Hvordan ? eksempel-beskrivelser !
Den Delphi(5)-hjælp jeg har kunnet finde til at lave filter på en tabel er meget sparsomt !
Hvad / hvormeget kan man egentlig ? og hvilken syntaks skal overholdes ?
Det har drillet mig en del, så jeg aldrig rigtigt fået has på det ! Kan man det samme som i en IF-sætning og/eller i SQL WHERE-betingelse ?
Jeg har leget en del med Range, baseret på et index, men problemet her, er at Range ophæves, når brugeren ændrer index ! og det ønsker jeg ikke i en konkret opgave...
To create a filter using the Filter property, set the value of the property to a string that contains the filter’s test condition. For example, the following statement creates a filter that tests a dataset’s State field to see if it contains a value for the state of California:
You can also supply a value for Filter based on text supplied by the user. For example, the following statement assigns the text in from edit box to Filter:
Dataset1.Filter := Edit1.Text;
You can, of course, create a string based on both hard-coded text and user-supplied data:
Blank field values do not appear unless they are explicitly included in the filter:
Dataset1.Filter := \'State <> \'\'CA\'\' or State = BLANK\';
Note: After you specify a value for Filter, to apply the filter to the dataset, set the Filtered property to True.
Filters can compare field values to literals and to constants using the following comparison and logical operators:
Operator Meaning < Less than > Greater than >= Greater than or equal to <= Less than or equal to = Equal to <> Not equal to AND Tests two statements are both True NOT Tests that the following statement is not True OR Tests that at least one of two statements is True + Adds numbers, concatenates strings, ads numbers to date/time values (only available for some drivers) - Subtracts numbers, subtracts dates, or subtracts a number from a date (only available for some drivers) * Multiplies two numbers (only available for some drivers) / Divides two numbers (only available for some drivers) * wildcard for partial comparisons (FilterOptions must include foPartialCompare) By using combinations of these operators, you can create fairly sophisticated filters. For example, the following statement checks to make sure that two test conditions are met before accepting a record for display:
(Custno > 1400) AND (Custno < 1500);
Note: When filtering is on, user edits to a record may mean that the record no longer meets a filter’s test conditions. The next time the record is retrieved from the dataset, it may therefore “disappear.” If that happens, the next record that passes the filter condition becomes the current record.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.