Topic: record save clicking print button

Hi Friends,
                  I am new here. I made a projet which is creating  a problem. When I click print button, it save the record too. Any solution plz.

Re: record save clicking print button

Hello.


That's how it was meant to be. Print button gets data from database, so it guarantees that the actual data from the form is included in the report.


Please, let me know, why is this a problem for you?

Dmitry.

Re: record save clicking print button

I made two form. On form one, I placed two buttons save and print and some textboxes to feed record. Form one use to feed form two which have table grid to show records. When I press save button, it saves records and shown on table grid of other form but print button also saves the record and prints records too. So I get double entry of record in table grid.

Re: record save clicking print button

Please attach your project (zip file without exe and dll)

Dmitry.

Re: record save clicking print button

Hello unforgettable, Hello Dmitriy

A question by the way :
What type of button do you use for the Print button?
If it is a button chosen from the toolbar, what action do you use: Report, report SQL?
If it's an image (acting as a button), which script do you place behind the OnClick event?
Simple curiosity

JB

Re: record save clicking print button

Create events OnClick and OnAfterClick for the report button, where you can temporally disable action of button to prevent saving a record, example:


procedure frmAbonent_ButtonReport_OnClick (Sender: TObject; var Cancel: boolean);
begin
    frmAbonent.ButtonSave.dbActionType := adbNone;
end; 

procedure frmAbonent_ButtonReport_OnAfterClick (Sender: TObject);
begin
    frmAbonent.ButtonSave.dbActionType := adbSaveRecord;
end;
Dmitry.

Re: record save clicking print button

Sir
  I am sending you your barcode project back with adding print button on frmemployee form. Run project and add a record then press OK it will save the record and show on table grid. After pressing OK now press print button and look what's happened? It save the record too show on tablegrid.
How can we solve this problem?

Post's attachments

Attachment icon BARCODE_fixed.rar 294.51 kb, 262 downloads since 2020-04-03 

8 (edited by ehwagner 2020-04-03 16:41:20)

Re: record save clicking print button

unforgettable,
To prevent the save from adding the same record multiple times while keeping the form open, you need to put in a piece of code. See attached.

Post's attachments

Attachment icon BARCODE_Save_fixed.zip 338.6 kb, 365 downloads since 2020-04-03 

Re: record save clicking print button

Dear Ehwagner,
                       Your codes work only on this project by not mine. Codes typed by admin work very well.

Re: record save clicking print button

unforgettable,
I can assure you that the piece of code I provided will work on any project if it is defined correctly. You need to understand how to assign events on forms and controls. If you do not assign the same name to button click procedures as Dimitry assigned  in his example, it will not work either. If you need help in defining procedures and triggering events let us know.

Re: record save clicking print button

I am new to MVD. It is my pleasure if you guide me Ehwagner.

12 (edited by ehwagner 2020-04-13 20:12:36)

Re: record save clicking print button

unforgettable,
I got a chance to put something together for you to help you to understand events and how to trap and define procedures to execute on defined events. Hopefully you can understand the attached pictures. I'm not a trainer or documentalist so to speak, but hopefully it will help in guiding you in the right direction. I don't think I can post the two pictures I have in one post so I'll submit another post with the second picture.


Also, the following resources can help with the events and other pascal coding.
http://myvisualdatabase.com/help_en/   Scroll down to the "Script" section on the left side.
http://www.delphibasics.co.uk/

The Run Time Library Reference on the right side of the delphibasics website is a good resource. Not everything in Delphi is defined in MVD, but a good number are used in MVD.

Post's attachments

Attachment icon Events.PNG 64.59 kb, 120 downloads since 2020-04-13 

Re: record save clicking print button

unforgettable,
Attached is the second picture for you regarding events.

Post's attachments

Attachment icon Script.PNG 68.62 kb, 122 downloads since 2020-04-13