Solved

Table1.Filter??

Posted on 2001-06-30
9
2,028 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
  • 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now