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.
My Visual Database → General → 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.
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?
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.
Please attach your project (zip file without exe and dll)
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
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;
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?
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.
Dear Ehwagner,
Your codes work only on this project by not mine. Codes typed by admin work very well.
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.
I am new to MVD. It is my pleasure if you guide me Ehwagner.
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.
unforgettable,
Attached is the second picture for you regarding events.
My Visual Database → General → record save clicking print button
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi