Re: Break into the Form Close event

From: Edgar Rodriguez (edgarrod_at_programmer.net)
Date: 10/09/03


Date: Thu, 09 Oct 2003 08:08:59 -0500

Use onCloseQuery event instead.

Edgar Rodriguez
edgarrod@programmer.net

On Thu, 09 Oct 2003 12:11:44 +1000, Pat Mc
<patabc@NOSPAMozemail.com.au> wrote:

>Hi,
>
>Got a form with a database table
>
>Got an OK button that checks certain fields before saving the table.
>It will not let you save the record unless these fileds are filled in.
>This works well.
>
>I have a procedure on the form CLOSE event and this checks if any
>changes are made and asks you if you want to saved them. If I say YES
>it checks if certain fields are filled in but then closes the FORM (
>it does not stop and set the focus to the field that needs filling in)
>
>Question is how can I stop the FORM from closing from the FORM Close
>event (I know that the Form Close event's job is to close the form,
>but how can I break into this event)?
>
>Should I design my form better?
>Note: I did not design the Form Close procedure below, it was a code
>snippet I had.
>
>Thanks for any replies,
>Pat
>
>-----------------------------------------------------------------------------------------
>procedure TMyForm.btnOKClick(Sender: TObject);
>begin
>
> if CheckFields=1 then
> begin ShowMessage(' Surname field is blank.. ');
> editSurname.SetFocus; exit; end
> else if CheckFields=2 then.........
>
>end
>-----------------------------------------------------------------------------------------
>procedure TMyform.FormClose(Sender: TObject;
> var Action: TCloseAction);
>begin
> if MyTable.State in [dsInsert, dsEdit] then
> begin
> if (MyTable.State = dsInsert) and (MyTable.Modified <> true) then
> begin
> btnCancelClick(sender); Action := caFree;
> end
> else
> case Application.MessageBox(PChar('Do you want to save
>changes?'),
> PChar(Application.Title), mb_YESNOCANCEL + mb_DefButton1 +
>mb_IconWarning)
> of
> IDYES: begin btnOKClick(sender); Action := caFree; end;
> IDNO: begin btnCancelClick(sender); Action := caFree; end;
> IDCANCEL: Action := caNone;
> end;
> end
> else Action := caFree;
>end;
>-----------------------------------------------------------------------------------------



Relevant Pages

  • Re: Buttons stop working sporadically
    ... I have this happen to me occasionally after I compact the database. ... the form in design view, then returning to form view, then saving, usually ... fixes it. ...
    (microsoft.public.access.forms)
  • C# programmer looking for a job
    ... Software Development including Desktop, Client/Server and Database ... Practical skills in object oriented design and design patterns ... XML, Oracle, CVS, VSS, Delphi, bug tracking. ... Developed in Delphi5; ...
    (misc.immigration.usa)
  • Re: O/R Mapper
    ... | - create E/R model from niam model ... classes that contain, not only data, but also functionality as OO design is ... a database where they do not exist in the object model is corrupting the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Date range on reports
    ... > box to your report with a control source like: ... >> In the Database window (Database window: The window that appears when you ... >> In the New Form dialog box, click Design View, and click OK. ... >> Begin by clicking Macro Names to display the Macro Name column. ...
    (microsoft.public.access.reports)
  • Re: teaching relational basics to people, questions
    ... the number of tables in the design, and think that conflating multiple fact ... metadata heaven where we have all of the formal semantics of our data ... model neatly encoded within the database catalog, and further, we have ... So I think this thing is mostly about UI design and formal conceptual ...
    (comp.databases.theory)