Options

Attaching a temporary Table to TableBox

gurleengurleen Member Posts: 39
Hi,
I want to use a temporary table with a TableBox. The only option that I can see on the form is to use a tablename which would not link me to the temporary table that I created on the form.

What I want to do is to load data from a txt file and show it in the TableBox.

Thanks

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,096
    2 possibilities:
    1) create your form like for a normal table.
    Create another object where you fill up a temptable and then
    FORM.RUNMODAL(FORMS::"My Form",tmpMyTempTable);
    
    This will make your form work on the temptable.

    2) through code in your form
    Code for "Form - OnFindRecord":
    tmpMyTempTable.COPY(Rec);
    blnFound := tmpMyTempTable.FIND(Which);
    Rec := tmpMyTempTable;
    EXIT(blnFound);
    
    code for "Form - OnNextRecord":
    tmpMyTempTable.COPY(Rec);
    intResultSteps := tmpMyTempTable.NEXT(Steps);
    Rec := tmpMyTempTable;
    EXIT(intResultSteps);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    gurleengurleen Member Posts: 39
    Can you explain what is going on in the second approach. Does this approach work with multi user environment ? Also would'nt I need to attach the table to the form ?

    The whole senario is as follows.

    I have a form on which I open up a text file( csv file with 2 columns). After the file opens I want to show the contents in the TableBox.
    Steps that I am taking:
    1. Use Common Dialog and get the file name.
    2.Open the file and read each line.
    3. Parse the line and load it in the tmp Table
    4. Show the temp table in the TableBox ( stuck at this)
  • Options
    DenSterDenSter Member Posts: 8,304
    I think you'd be better off using approach 1. Start a codeunit instead of a form from where the user clicks. In this codeunit you program the common dialog to browse to the file and import it into the tmptable, then you call the form based on the tmptable with RUNMODAL, so that the codeunit waits until your form exits to finish up.
  • Options
    gurleengurleen Member Posts: 39
    Thanks DenSter and kriki

    I had already started coding kriki's approach and it works. I queried the database using enterprise manager and the data seems to stay in the temp table only ( query analyser showed no rows in the database), which hopefully means that every user will get it's own instance of the table. It will be nice if kriki can explain how it's working.

    Also can a user be logged into the system from more than one client at the same time ie can USERID be the same for two logged on users
  • Options
    DenSterDenSter Member Posts: 8,304
    When you declare a variable of datatype Rec, you're not looking directly into the table. It's basically declaring a class that is structured exactly like the table that the variable is based on. The variable is basically just a piece of memory that behaves like a table.

    By default, the system connects the class to the table for you, so you don't have to worry about connection strings and such. You have the choice to not connect to the table by making it a temporary variable. That way you have a variable in memory that acts exactly like a table that you know, but it is not connected to your database.
  • Options
    krikikriki Member, Moderator Posts: 9,096
    I think DenSter explained nicely what happens in Navision with a record-variable that is temporary.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.