open new sub-stack with different record from database

Jan Schenkel janschenkel at yahoo.com
Sat Jun 7 02:05:06 EDT 2008


--- mfstuart <mfstuart at cox.net> wrote:
> 
> Hi all,
> 
> WINXP
> Rev 2.9
> MSSQL
> 
> How do I build an MDI interface where from a list of
> records the user can
> open multiple instances of a sub-stack with a
> different record on each
> sub-stack?
> 
> Current setup:
> Main Stack - table list of records from a SQL
> database.
> Sub-stack - reads and displays the selected record.
> 
> [snip]
> 
> Problem:
> If the user double clicks again on a different
> record on the table list, the
> currently opened sub-stack becomes focused with the
> first opened record
> displayed, not the second selected record.
> I can't open more than one sub-stack at a time?
> 
> TIA,
> Mark Stuart
> 

Hi Mark,

You should look at the 'clone' command - keep a
pristine template stack around, and clone that stack
every time the user double-clicks the field - though
you should probably move it into a utility handler so
you don't have to copy the logic when you want to edit
customer records from elsewhere in your application.

Also consider setting the 'destroyStack' property of
the cloned stack - that way, when the stack is closed
by script or by clicking the close button, the memory
it takes up will be freed. And you may also want to
set the label and name of the cloned stack at the same
time.

So you would end up with something like this:
##
global gAccountNumber

on mouseDoubleUp
  set the itemDel to tab
  put item 1 of the selectedText into gAccountNumber
  if gAccountNumber <> "" then
    clone stack "EditAccountTemplate"
    set the destroyStack of it to true
    set the label of it to "Edit Account" &&
gAccountNumber
    set the name of it to "EditAccount" &
gAccountNumber
  end if
end mouseDoubleUp
##

Hope this helped,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list