Board index » delphi » Changing DisplayFormat in code

Changing DisplayFormat in code

What a day to quit caffine!!

This should be stupid easy.  I want to change the displayformat of a
DateTime field in my code.  (I know I can set this up by right clicking the
Query icon, but it has to be dynamic)

THANKS

 

Re:Changing DisplayFormat in code


I thought so too, but I get the following error:

Undeclared Identifier 'DisplayFormat'

Quote
Bill Todd (TeamB) wrote in message <6ve77q$kr...@forums.borland.com>...
>Query1.FieldByName('SomeField').DisplayFormat := '###';

>--
>Bill Todd
>(Sorry but TeamB cannot answer questions received via email)
>(Remove nospam from my email address to contact me for any other reason)

Re:Changing DisplayFormat in code


Quote
On Tue, 6 Oct 1998 20:53:36 -0400, Vinnie Schoenfelder wrote:
>I thought so too, but I get the following error:

>Undeclared Identifier 'DisplayFormat'

DisplayFormat isn't native to all field types, just numeric and
date/time fields. You need to cast the FieldByName result to the
correct field class.

sig://boB/TeamB

Re:Changing DisplayFormat in code


I left out a step.  You need to cast to the type of the field.  Try

Table1.(FieldByName('SomeField') as TIntegerField).DisplayFormat := ...

Note that not all field types have the DisplayFormat property.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads