[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Ttable question

Posted on 2004-09-28
7
Medium Priority
?
393 Views
Last Modified: 2010-04-05
I placed a Ttable component in FORM1, then double click on the Ttable component. There is a  FORM1.Table1 that will pop-up, then i tried to create a new field.

The above procedure is done manually, how about if i will make that procedure above dynamic like having a source code to create a new field from the FORM1.table1.

How will i do that?
0
Comment
Question by:girlswants_me
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 1

Expert Comment

by:SJohnson
ID: 12176937
A TTable is supposed to be linked to a database table.  It's not supposed to be just used as a stand alone component.   When you connect it to a TTable, it will automatically populate itself with the field values.

If you want to add a new calculated or lookup field to the Ttable, you can do that with the FieldDefs property (look in the help for FieldsDefs.Add).  It's quite easy to do.

Stu.
0
 

Author Comment

by:girlswants_me
ID: 12177262
Hi Sjohnson,

Yes i can add field with my TTABLE even though without having a database table linked to it. Try this.
1. Double click on any Ttable component and a tool window will popup
2. Right click inside the tool window (Form1.Table1) and select "New Field..."
3. Now, a NEW FIELD dialog will come out. Place any values on the fields under NEW FIELD dialog.
4. You will now have a field inside the Form1.Table1 tool window.

Does FieldsDefs.add() method is the same as above?
0
 

Author Comment

by:girlswants_me
ID: 12177273
And if FieldsDefs.add() is the same as what i did on the procedures, how can i assign a code inside the event OnGetTex(Sender: TField; var Text: String;  DisplayText: Boolean) ?

procedure TForm1.CurrencyGetText(Sender: TField; var Text: String;
  DisplayText: Boolean);
begin
 Text:='The value is ' + Sender.asstring;
end;
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:SJohnson
ID: 12177284
I'm just on my way home now, so I'll look at this more closely when I get home.

When you add the field definitions manually (through the IDE), can you actually populate those fields with data?  Do you set a TableName as well?  I've just never done it like this before (I guess I can't see why it won't work).

Stuart.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12177409
Note:
  AddFieldDef is only valid in the context of creating field definitions for a table to be created with a subsequent call to the CreateTable or CreateDataSet method. It cannot be used to add fields to an already-existing table.
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 500 total points
ID: 12177496
procedure TForm1.SpeedButtonCreateParadoxTableClick(Sender: TObject);
var
  S:      string;
begin
  S := ExtractFilePath(Application.ExeName) + 'SINGERS.DB';
  with Table1 do
  begin
    Active := False;
    DatabaseName := '';
    TableType := ttParadox;
    TableName := 'SINGERS';

    try
      { Don't overwrite an existing table }

      if not Table1.Exists then
      begin
        { The Table component must not be active }
        { First, describe the type of table and give }
        { it a name }
        { Next, describe the fields in the table }
        with FieldDefs do
        begin
          Clear;
          with AddFieldDef do
          begin
            Name := 'ID';
            DataType := ftAutoInc;
            Required := True;
          end;
          with AddFieldDef do
          begin
            Name := 'ALL_NAMES';
            DataType := ftString;
            Size := 32;
          end;
        end;
        { Next, describe any indexes }
        with IndexDefs do
        begin
          Clear;
          { The 1st index has no name because it is
          { a Paradox primary key }
          with AddIndexDef do
          begin
            Name := 'Primary_Key';
            Fields := 'ID';
            Options := [ixPrimary];
          end;
          with AddIndexDef do
          begin
            Name := 'ALL_NAMES_Indx';
            Fields := 'ALL_NAMES';
            Options := [ixCaseInsensitive];
          end;
        end;
        { Call the CreateTable method to create the table }
        CreateTable;
      end;
    finally
      Table1.Active := True;
    end;
  end;
end;
0
 

Author Comment

by:girlswants_me
ID: 12177758
Thanks a lot.
0

Featured Post

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

656 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