Canceling a forms OK button
Canceling a forms OK button
So when a user presses an OK button on a report form whose dialog default is set to "OK" I would like it to check to make sure that all of the form data is filled in before running the report. If it is not then pop up a message and cancel running the report. I have been able to code my form to check the fields and pop up a message box, but I do not know how to cancel running the report. Any help would be appreciated.
Thanks,
Mat
Thanks,
Mat
Canceling a forms OK button
Set property DialogResult to None. After then use following code:
Thank you.
Code: Select all
if (condition)Form1.Close();
else ......
Re: Canceling a forms OK button
Hello,
I'm having the same request. Thanks to this topic, I've managed to write this code:
if everything is OK, the form should be closed and the report should run. With this code, the form is well closed, but the report is blank. Do I miss something in my code to render the report?
Thank you.
I'm having the same request. Thanks to this topic, I've managed to write this code:
Code: Select all
if (TextBoxControl1.Control.Text=="")
{MessageBox.Show("Please enter the first sample number");}
else
{
labels.Connect();
Traits.Connect();
Form1.Close();
}
Thank you.
Re: Canceling a forms OK button
Hello,
Any idea to answer my question?
Thanks
Any idea to answer my question?
Thanks

Re: Canceling a forms OK button
Hello,
Can you please send us a sample report with test data which reproduce the issue for analysis.
Thank you.
Can you please send us a sample report with test data which reproduce the issue for analysis.
Thank you.
Re: Canceling a forms OK button
Sure.
I'm joigning the original report, which is working: and the modified report which is not working: and the data file: The modified report asks that the user must enter something in the form.
Thank you.
I'm joigning the original report, which is working: and the modified report which is not working: and the data file: The modified report asks that the user must enter something in the form.
Thank you.
Re: Canceling a forms OK button
Hello,
In this case you close form without render report and get the blank page.Please try to set the DialogResult property for the "Ok" button as Ok,
Thank you.
In this case you close form without render report and get the blank page.Please try to set the DialogResult property for the "Ok" button as Ok,
Thank you.
Re: Canceling a forms OK button
Thank you for your reply.
I tried this. But when there is an empty string in the TextBox, the message is well displayed to the user, but the report is rendered (and showing an error message "Input string was not in a correct format."), instead of showing again the form so that the user can type something.
Look at the modified report: Thanks.
I tried this. But when there is an empty string in the TextBox, the message is well displayed to the user, but the report is rendered (and showing an error message "Input string was not in a correct format."), instead of showing again the form so that the user can type something.
Look at the modified report: Thanks.
Re: Canceling a forms OK button
Hello,
Please try to use the following code:
Thank you.
Please try to use the following code:
Code: Select all
if (TextBoxControl1.Control.Text=="")
{
MessageBox.Show("Please enter the first sample number");
this.IsStopped = true;
}
else
{
labels.Connect();
Form1.Close();
}
Re: Canceling a forms OK button
Thanks but it's not working. The code "this.IsStopped = true;" doesn't stop the report rendering.
Any other idea?
Thank you.
Any other idea?

Thank you.