[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Dispaly modal form and showmessage error

Posted on 2007-10-02
8
Medium Priority
?
372 Views
Last Modified: 2010-04-05
I have two forms in an app, one which I will call the main form and a second form which is opened as a result of a button click that is called via the following piece of code

AddNewClassForm.ShowModal;

While the second form is displayed if I try to send an error via the showmessage routine, when the user clears the message the second form is closed also any idea how to bypass
0
Comment
Question by:elschott
8 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 19996824
Can you show us your code please.
A showMessage call has nothing to do with forms, so you must be doing something else as well.
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 19997123
The answer might lie in the help file on Showmodal (See the "Note" below)

Use ShowModal to show a form as a modal form. A modal form is one where the application can't continue to run until the form is closed. Thus, ShowModal does not return until the form closes. When the form closes, it returns the value of the ModalResult property.
 
To close a modal form, set its ModalResult property to a nonzero value.
 Note:
 If the form contains buttons with a ModalResult property set to a value other than mrNone, the form automatically closes when the user clicks one of those buttons and returns the ModalResult value as the return value of ShowModal.
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19997522
Can you explain more.






0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:MerijnB
ID: 19997748
can you please show some code like mikelittlewood requested?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19998725
i think below solution will work for you.
But believe that this not good solution. You have to find the reason.



ShowMessage('fgdfgdfg'); //your error message.
AddNewClassForm.ModalResult:=mrNone;
0
 

Author Comment

by:elschott
ID: 20002927
The call from form 1 to display the AddNewClassForm is from a button click as follows:

Add_New_Subject_Form.ShowModal;

The Add New Subject Form basically has 4 fields and two buttons a submit and a cancel. I want to check if the user presses the submit button that all fields have values entered, if not show an error and return to the form, if the form is completed correctly the database record is appended to the dataset and the user is returned ot the original form here is the submit code I hope it helps

begin
  If (AddFaculty.Text = '') or (AddSubjectName.Text = '') then
    begin
      ShowMessage('All form fields are mandatory. Please complete form to add new subject');
    end
  else
    begin
      Maintennance_Form.SubjectID.Text := AddRecNum.Text;
      Maintennance_Form.DBLookupCombobox1.SetText(AddFaculty.text);
      Maintennance_Form.Subject_Name.text := AddSubjectName.text;
      Maintennance_Form.Subject_AcaLvl.text := SelectYearCB.Text;
      Datamodule1.SubjectSource.DataSet.Post;
      Close;
    end;  
end;

I took out the dataset.post and close lines and put another showmessage in there, which should show the message and then return to the form but when this show message is displayed it still closes the add new subject form, which made me think it had something to do with showmessage and showmodal

Thanks

Jake
0
 
LVL 13

Accepted Solution

by:
rfwoolf earned 2000 total points
ID: 20003907
Hi elschott

As I mentioned earlier the answers might lie in the help file.
Here " If the form contains buttons with a ModalResult property set to a value other than mrNone, the form automatically closes when the user clicks one of those buttons and returns the ModalResult value as the return value of ShowModal."

In other words, check the "modalresult" property of the buttons on your "Add_New_Subject_Form". If they are set to ANYTHING other than "mrNone" they will close the Add_New_Subject_Form!
0
 
LVL 10

Expert Comment

by:dinilud
ID: 20004056
i agree with  rfwoolf.
You are closing your form with 'CLOSE' function.
So the model result of your Submit button must mrNone.
 
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question