Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to remove/deselect tables at runtime...

edited July 2002 in General
Hi,

I'm converting some saved reports (RTM files) after moving some database
fields from one table to another. This means I have to effectively remove
three tables from the report template. I am currently looping over the
report objects and changing the Fieldname and Tablename properties of the
field components so the design layout info will be updated.

But how to I update the query information? I have code to retrieve the SQL
object, and now I want to remove three of the tables that may be selected
for this report. I tried calling RemoveTable but it didn't work. I thought
DeselectTable might work, but the parameter is a table index which I don't
know how to get.

I'm kind of floundering now. What would be the best way to "deselect" the
tables from the report now that those tables will no longer exist in the
database? Do I do this as part of the SQL object or is it stored elsewhere?

Any help in this regard would be greatly appreciated.

Thanks,
Vinnie Murdico

Comments

  • edited July 2002
    DeselectTable should do it. Make sure you deselect the last table first (you
    don't want to rip out tables that other tables are joined to.) The
    'TableIndex' simply refers to the position of the table in the SelectTables
    array property. Deselecting the last three tables:

    for liIndex :=0 to 2 do
    lSQL.DeselectTable(lSQL.SelectTableCount - 1);

    To find a given table:

    liIndex := lSQL.IndexOfTableAlias('myTableAliasFromDataDictionary');

    if (liIndex = -1) then
    {table not found}

    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
This discussion has been closed.