DriveSoft wrote:Hello.
Print button also save record, because use data from database, not from form.
You can prevent it, example:
procedure Form2_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
if Form2.Button1.dbGeneralTableId = -1 then Cancel := true;
end;
Thanks a lot Dmitry.....
The above stops saving onClick of print button. However, print button appears as active button, clicking on it doesn't do anything. I tried to add info message
procedure Form2_Button2_OnClick (Sender: string; var Cancel: boolean);
var
buttonSelected : Integer;
begin
buttonSelected :=MessageDlg('Only saved records can be printed.', mtInformation,mbOK,0);
begin
if Form2.Button1.dbGeneralTableId = -1 then Cancel := true;
end;
end;
Unfortunately, info message is displayed on show record too beside showing print preview. I couldn't get it right to stop info message showing on show record / print.
Then I used disable print button on new record, and enable on show record.
procedure Form1_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
Form2.Button2.enabled := false;
end;
procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
Form2.Button2.enabled := true;
end;
I'm not sure if this is the correct approach tho.
Adam
God... please help me become the person my dog thinks I am.