You cannot make any changes to the database until a trans...

bhalpinbhalpin Member Posts: 309
Hi.

The full error is:

You cannot make any changes to the database until a transaction has been started

Here is the situation:

Customer's Item table is full. Yup, full. There's a whole bunch of custom fields so there's no room for what I need to add.

I have though of disabling some fields that I know they will never use, but I think that's bound to be a dsaster when some code down the line references a field I've disabled. (I don't want to take that phone call!)

So, my plan is to create an item 'companion' table where I can add all the fields I want to. That's done. And, on the item card I've added a new tab, and on it I've placed a subform for the new table. That works.

Now the problem is keeping the subform 'companion' record synchronized with the item the main form is on. This would involve creating the companion record 'on demand' as the user moves from item record to item record.

Naively I put the following code in the OnAfterGetRecord() trigger:
IF NOT ItemCompanionRecord.GET("No.") THEN BEGIN
  ItemCompanionRecord.INIT;
  ItemCompanionRecord."No." := "No.";
  ItemCompanionRecord.INSERT;
END;
When I click on Next Record - *Poof* -I get the error above. Duh, of course, I've seen this before. :oops:

I've read posts here on this error and one suggestion was to put code like that in the item record and call that from the form trigger. Nope, same error.

So, I'm wondering if there is any way of achieving this functionality.

My alternative is to do a quick report to create companion records for all the existing items, and create new companion record from the OnInsert() trigger of the item table. (I've tried it, and it works.)

But, for some reason I prefer the first method - if it's possible.

Thanks in advance for any suggestions!

Answers

  • SavatageSavatage Member Posts: 7,142
    I admit I read that post quickly but can I assume the key for the companion table is also "No."

    2nd I will assume you set up the SubFormID & SubFormLink properly?

    3rd I will assume you want the extra item data to be entered into a created companion table form?
  • bhalpinbhalpin Member Posts: 309
    Hi.

    Yes, you're correct on all three counts.

    Also, I should have added that this is NAV 4.0 SP3.
  • JohnConJohnCon Member Posts: 55
    If you are using a subform and have the link setup correctly you shouldnt need to create the companion record in code. It will create when the user enters data on the first non-key field of the companion subform.
    If you always want a companion item record then I would suggest that you auto create all of the existing items new companion records through a report and then in the on insert trigger of the table you create the companion and in on delete trigger of the table you delete the companion. that way the existing items will have a companion record and all new items will have a record.
  • bhalpinbhalpin Member Posts: 309
    If you are using a subform and have the link setup correctly you shouldnt need to create the companion record in code. It will create when the user enters data on the first non-key field of the companion subform.

    Wow, that rings a bell - I'll look into that.

    Thanks!!!

    Bob
  • SavatageSavatage Member Posts: 7,142
    That's why I had to ask if you set that up correctly 8)
  • bhalpinbhalpin Member Posts: 309
    Hi.

    Maybe I spoke too soon and the subform isn't configured quite right.

    Fo now, I went with the option of simply creating all the 'companion' records with a report. All is well exceopt for one thing.

    On the item card, when on an Item field, I PgUp/PgDn (Rec Prev/Rec Next), the 'companion record displayed in the subform stays in synch just fine.

    But if I make a field on the companion subform active and PgUp/PgDn, the 'companion' record moves independantly of the 'main' item record.

    How do I either disable the record movement from within the subform, or make the main form 'follow' the subform. (I don't care whitch, as long as they stay synchronized.)

    BTW: Subform: SourceTaleRecord & SourceTableVew props are <undefined> - that looked like where I should focus, but haven't found the 'magic'.

    Thanks!!!!!
  • bhalpinbhalpin Member Posts: 309
    Got it - I just put EXIT; in the OnNextRecord trigger and now PgUp/PgDn is disabled in the sub-form.
Sign In or Register to comment.