Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Conform exit of designer when changed

edited July 2003 in General
Hi,

I've been looking for this, it should be very simple(and standard imo).

Why doesn't the reportbuilder designer ask confirmation when being closed
and changed are made without saving?

Tnx for your time

Franky

Comments

  • edited July 2003
    I agree it would be nice to have this as an option, but you can do it
    yourself without too much effort.

    This code is called in the OnCloseQuery event of the designer. If the
    report has been modified, it asks if the user wants to save it before
    exiting. If the report is a new report and no name has been assigned to the
    template yet, it prompts for a name assuming the user said "Yes" to the "do
    you want to save it now?" question.

    If (ppDesigner.Report.Modified) Then
    begin
    MessageBeep(mb_IconExclamation);
    Btn := MessageDlg('This report has not been saved. Do you want to
    save it now?', mtConfirmation, [mbYes, mbNo, mbCancel], 0);
    If (ppReport.Template.DatabaseSettings.Name = EmptyStr) and (Btn =
    mrYes) Then
    begin
    NewRptName := EmptyStr;
    If (InputQuery('Report Name', 'New Report File Name:', NewRptName)
    = True) and (Trim(NewRptName) <> EmptyStr) Then
    begin
    Btn := mrYes;
    ppReport.Template.DatabaseSettings.Name := NewRptName;
    end
    Else
    Btn := mrCancel;
    end;
    If (Btn = mrYes) Then ppReport.Template.SaveToDatabase;
    CanClose := (Btn <> mrCancel);
    end;

    --
    Vinnie Murdico
    Software with Brains, Inc.
    SWBTracker - Professional Bug Tracking Software
    http://www.softwarewithbrains.com
  • edited July 2003
    Thanks Vinnie :)

    Why didn't i think of that..Friday evening, i guess i wasn't focused anymore
    :p

    This is the code i used, works perfect indeed, thanks.

    procedure TFormplanner.DesignerCloseQuery(Sender: TObject;
    var CanClose: Boolean);
    Var Res:Byte;
    begin
    If Designer.Report.Modified Then
    Begin
    Res := MessageDlg('Report is changed, Save
    now?',mtConfirmation,mbYesNoCancel,0);
    If Res = MrCancel Then
    Begin
    CanClose := False;
    End Else
    Begin
    If Res = mrYes Then Report.Template.SaveToFile;
    End;
    End;
    end;

    Franky

This discussion has been closed.