Solved

Table1.Filter??

Posted on 2001-06-30
9
2,066 Views
Last Modified: 2012-06-21
I want to filter my database with;
Table1.Filter := 'NAME = DateToStr(DateTimePicker1.Date);
Table1.Filtered := True;

But it says

Table1: Field 'DateToStr'not found...

But if i try
Table1.Filter := 'NAME = ''SYS''';
Table1.Filtered := True;

it works. But i want user choose date to filter? How can i do this??
0
Comment
Question by:systemop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 1

Expert Comment

by:cobramania
ID: 6240833
try set that at run time
Table1.Filter := 'NAME = DateToStr(DateTimePicker1.Date);
not design time

or try
dtTemp:= DateToStr(DateTimePicker1.Date);
Table1.Filter := 'NAME = dtTemp;

at runtime

hope this helps
0
 

Author Comment

by:systemop
ID: 6240875
neither of them works..
0
 
LVL 1

Expert Comment

by:cobramania
ID: 6240973
i don't have delphi in my comp now,
Table1.Filter shouldn't have variable

try this:

str:= 'Name='+DateToStr(DateTimePicker1.Date);
Table1.Filter := str;

hope this helps:)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6240994
near cobramania,
but i would guess it should be

str:= 'Name='+QuotedStr(DateToStr(DateTimePicker1.Date));
Table1.Filter := str;
Table1.Filtered := True;

meikl ;-)
0
 
LVL 3

Expert Comment

by:marcoszorrilla
ID: 6240997
Thats works correctly try it.



Europe
Table.Filter:='My_Date >= '+''''+formatDateTime('dd/mm/yyyy',fIni)+'''';
Table1.Filtered:=True;

America
Table.Filter:='My_Date >= '+''''+formatDateTime('mm/dd/yyyy',fIni)+'''';
Table1.Filtered:=True;
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6241279
The format of date has to meet the requirements of the database as well.

Access wants the date to surrounded by the number symbol instead of quotes. Something this
#mm/dd/yyyy#

And Sybase wants the format to be yyyy/mm/dd.

I believe Paradox is mm/dd/yyyy.

Because of these variants and in my opinion I think you would be better served if you used a Query instead of a Table for filtering dates so you could use the Params property instead of the Filter property.


The Crazy One
0
 

Accepted Solution

by:
ondertol earned 50 total points
ID: 6241421
You must write the Filter String as this format:

Table1.Filter := 'Name = ''' + DateToStrDateTimePicker1.Date) + '''';

where "Name" is the field name of your table;


If you want filtered your table with fixed date, can you write this string on property Filter on object inspector :

Name = '12/10/01' <--- this is a string constant

if you write this code on program, the same istruction is

Table1.Filter := 'Name = '' 12/10/01 '' ';
                 

The first and the last ' indicate at the Delphi compiler  
                         who this is a string value
the double '' is used into a string for indicate only one '

Now, if you examinate the first istruction of this comment can you understand the meaning:

the first ' is used for indicate: i have open one string
Name =, show the field name of table
into ''': the compiler translate two first '' at only
          one ' and the third ' is used for close
          the first part of string
DateToStr(...) return your date in string format (second
               part of string)
into '''': the first and the last ' il used for open and  
           close the third part of string and
           the central '' is translate by compiler
           to only one '

the istrunction, when is compiled is translate on this format:
table1.Filter := ' Name = '10/12/01' ';

if the value of DateTimePicker1.Date is 10/12/01

!!!!remember: set the Filtered property = True
0
 

Author Comment

by:systemop
ID: 6243906
Thank you ondertol
0
 

Expert Comment

by:ondertol
ID: 6246338
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question