Topic: Saving same record as a new record

I have tried something without success. Idea is converting sale/purchase invoice into refund and saving it as a new record next to original invoice sale/purchase inv record.


Please see the attached sample project

Post's attachments

Attachment icon Save as new record.zip 18.04 kb, 338 downloads since 2017-05-26 

Adam
God... please help me become the person my dog thinks I am.

Re: Saving same record as a new record

Hi Adam,
You could try something like this (see attached).  There's probably other(better) ways to do it but it seems to work.
I haven't looked at anything like negating values etc - just did the actual copy/create.
Hope this helps,
Regards,
Derek

Post's attachments

Attachment icon Save as new record.zip 352.47 kb, 372 downloads since 2017-05-26 

Re: Saving same record as a new record

Hi Derek,


Thank you very much for the sample.......................


Last couple of days I have been trying to achieve desired solution.
I have changed for all show/hide, disable/enable events around Invoice type combo onChange.


However, saving existing record (issuing a refund against existing sale/purchase invoice) issue is still outstanding. The way I'm trying to do this task as illustrated on the image below:

https://s4.postimg.org/wqmzoead9/zzzzz_Temp36.png

Post's attachments

Attachment icon Save as new record Test.zip 17.7 kb, 328 downloads since 2017-05-28 

Adam
God... please help me become the person my dog thinks I am.

4 (edited by derek 2017-05-28 20:44:11)

Re: Saving same record as a new record

Hi Adam,
Does the attached come closer to what you want?
If you select a purchase invoice from the grid, the frminvoice screen has a 'purchase refund' option.  The same goes for a sales invoice.
If the 'purchase refund' button is clicked, the button caption changes to 'Save Purchase Refund' and the transaction type changes to a 'Purchase Refund'.  The same goes for the 'sales refund' button.
If you select a purchase invoice refund, it automatically uses the originating purchase invoice as a cross reference.   The same goes for a sales invoice refund.
Because the script references the originating transaction automatically, I guess you don't need to be toggling the refund panel off and on (I've commented it out in the script).
The script itself is pretty messy now but there seemed little point in tidying it up until you're sure it's doing what you need.
Please note that on frminvoice, the 'purchase refund', 'sales refund', 'save purchase refund' and 'save sales refund' buttons all overlay one another (just in case you're wondering where they've all gone - LOL!).
Regards,
Derek.

Post's attachments

Attachment icon Save as new record.zip 354.02 kb, 359 downloads since 2017-05-28 

5 (edited by AD1408 2017-05-29 00:16:06)

Re: Saving same record as a new record

Does the attached come closer to what you want?


Hi Derek,


I wish I could have said big yes, but unfortunately it's not. However, I'm truly grateful for your kind efforts of help... Always...


I'm not sure if you have checked out my latest sample project named "Save as new record Test.zip " on post #3. There, all those show/hide, enable/disable events quite close to what I'm trying to achieve with the exception of hiding some Invoice Type combo items.
1. Hiding when adding new record. Since we can only issue refund for something received, I wanted to hide "Sale", "Sale Refund" and "Purchase Refund" combo items when we are adding a new purchase invoice. Smilarly, hiding "Purchase", "Sale Refund" and "Purchase Refund" combo items when we are adding a new sale invoice.
2. When user clicks on Edit selected Purchase Invoice, Invoice Type combo item "Sale Refund" should be hidden preventing user saving it as a sale refund by mistake.
3. When user clicks on Edit selected Sale Invoice, Invoice Type combo item "Purchase Refund" should be hidden preventing user saving it as a purchase refund by mistake.


Key point is when issuing a refund against an invoice (fully or partially) refund should be saved as a new record, not overwriting existing record as it currently does. Please see images (1,2,3 and 4) on the post #3. Hence the title of the post most important part is to achieve saving existing record as different/new record which I have no idea how to do it with using same table and form. Perhaps post title should have been Saving existing record as an another record.


Required overlying objects on the form can be done later on as needed. It's easier to manage them during work/test phase. I left Refund numbers panels separate atm but they will be overlaid once all working. I usually do cosmetics on later stages of the project .

Adam
God... please help me become the person my dog thinks I am.

Re: Saving same record as a new record

Adam, Maybe the attached is what you want. It's a little different approach, but it creates new refund records based on the sale or purchase invoice records. To issue a refund, select the row you want to refund and click on the issue refund button on Form1. You can only refund on "Sale" or "Purchase" rows in the respective grids. Once you are in the update form, you can't change the DbCr field. In fact the DbCr field will always be populated based on the button you press in Form1.


You have a lot of buttons going on in the frmInvoice form. I didn't do anything with them or any of your script. Didn't want to mess up anything you were applying with any of that.

Post's attachments

Attachment icon Save as new record Test 2.zip 599.27 kb, 419 downloads since 2017-05-30 

Re: Saving same record as a new record

Hi EHW,


Maybe the attached is what you want...

It's better than what I wanted... Admirable logic and coding skills you have...


Thank you very much................ Truly appreciated................

Adam
God... please help me become the person my dog thinks I am.