Options

problems with temporaray table while opening a form

shilpareddyshilpareddy Member Posts: 28
Dear All,

I have a table with the fields:

Variable DataType
Access Type Option (Public,Private);
User Name Text
and some other fields.........

Now I wanted to open a form based on the following conditions:
1. I should able to see all users of public
2. current user private and public records.

For this, I have tried with the following code....

REPEAT
IF RecordVariable."User Name" = USERID THEN BEGIN
RecordVariable2 := RecordVariable;
RecordVariable2.INSERT;
END ELSE
IF RecordVariable.AccessType = RecordVariable.AccessType::Public THEN BEGIN
RecordVariable2 := RecordVariable;
RecordVariable2.INSERT;
END
UNTIL RecordVariable.NEXT=0;

Here, RecordVariable2 is the temporary Variable.
With this, I can able to see the form but I am unable to insert new records
in the form

Moreover, we tried with MARK function also. Still we are getting the same problem.

So, if any body find a soultion for the problem..please reply.

Thanks,
With Regards,
Shilpa Reddy

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,090
    I suppose you do a FORM.RUNMODAL(FORM::"Some Form", RecordVariable2);

    When you insert/modify/delete a record, it happens on the temptable. So in the OnInsertRecord,OnModifyRecord,OnDeleteRecord, you have to write code to insert/modify/delete the record in the REAL table.

    eg. in the OnInsertRecord-trigger:
    recMyRealTable := rec
    recMyRealTable.INSERT(TRUE); // this generates an error if the record already exists in the real table
    EXIT(TRUE);
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    jmjm Member Posts: 156
    Hi,

    your problem is that if you use MARK function your new record is outside your filter and if you use temporary record it is not written to the database.
    Two ways to solve your problem:
    - use a form on a temporary record and fill the triggers
    OnInsertRecord, OnModifyRecord, OnDeleteRecord with statements which do the datebase update.
    - use one form to show the records in the described ways and use a new form to insert new record filtered with the field "User Name" = USERID.

    br
    Josef Metz
    br
    Josef Metz
Sign In or Register to comment.