Display dialog causing error - dialog

I have a simple dialog. The user can either accept the dialog or cancel it. But when I cancel, it errors. Why?
try
display dialog "I cause an error when my 'cancel' button is pressed."
on error error_message number error_number
display dialog "Error: " & error_number & ":" & error_message & "."
end try

Here's one that doesn't error!
display dialog "I won't cause an error because I specified the buttons myself and didn't include a cancel button!" buttons {"Quit", "OK"} default button 2

The Cancel button always causes an error in the display dialog command. You cannot fix that. However, if you do as #regulus6633 suggested and specify the buttons yourself, you won't have to worry about errors.

Related

Hiding the form while printing - strange behavior

I have created a form with a button that allows the user to print the selected sheet. Her absolutely minimized form is below.
Option Explicit
Private Sub btnPrint_Click()
lblHideCounter = lblHideCounter + 1
Me.Hide
Application.Dialogs(xlDialogPrint).Show
Me.Show False
lblShowCounter = lblShowCounter + 1
MsgBox "bntHide_Click, Show Counter: " & lblShowCounter
End Sub
Private Sub UserForm_Terminate()
MsgBox "UserForm_Terminate, Show Counter: " & lblShowCounter
End Sub
So that the form does not disturb the user when the printing dialog box is displayed, I decided to hide it and then show it back after printing. However, I noticed a rather unexpected behavior. Well, if the form is displayed in modal mode, the code that follows the Show command of the form will be run only after the form is finally closed (even after UserForm_Terminate event). If, on the other hand, the form is displayed in modeless mode, such a problem does not occur.
For some reasons, however, I would like my form to be displayed in modal mode. However, I am concerned that this behavior may result in problems (e.g. stack utilization?), if the user repeatedly presses print without closing the mold.
Can this be solved in some other way? For example, is it possible somehow (without using the Hide method) to hide the form while the print dialog is displayed and then display it again (without using the Show method)? Or maybe I shouldn't worry about this problem?
The file with example code can be downloaded from here..

If else not read properly after changes made to any document

I have a button in a form where I'm using If else to check whether in list of document in view, "IF" any document with status "Lock", I will prompt messagebox "Complete PC Inspection First!". So
At first, after the button is click, and code run and everything is working. Then I try to click the button again without made any changes it will prompt the messagebox.
But when I made a changes in any document and change status to others such as "Active", and I go back to the form and click the button, it not prompting the message, but it skip the first If and proceed to else.
Below is my code:
If doc.PStatus(0) = "Lock" Then
Msgbox "Complete PC Inspection first!"
Exit Sub
Else
answer% = Messagebox("Do you confirm with this infomation?", 4,"Batch Number")
Some code...
...
End If
What I want to do is the button will not proceed to "else" if there still have "Lock" status in any document in the view. It will continue to "else" when there is no "Lock" status in the view. Any help will be appreciated. Thanks!
Better use a view that contains all Locked documents, ordered by the PC key or so. Or use a view sorted by key and Status, so you can pick out all locked documents for a specific PC. If there aren't any, GetDocumentByKey will return Nothing.

Why does my error message display quickly, then disappear right away

I have a save button on my xpage. I have field edits inside of the button. I did that because when I put the edit in the field validation, it runs when I open a new xpage. Either way though, I have an Error Message control on the form. When I click the save button, it flashes yellow then disappears. Why is this occurring? It's simple code:
if(getComponent("ExpAmt").getValue() == null) {
#WarningMessage("You must enter an Amount for this expense");
return false;
}
Partial refresh message box displays saying:
An error occurred while updating some of the page.
Unable to load http://localhost/DB.nsf/xpForm.xsp?$$ajaxid=view%3A_id1%3A_id3%3A_id4%3ApanelAll status: 0
There is a partial refresh in your ccApplicationLayout that runs onClientLoad. It was immediately refreshing the panel after the page was loaded which caused the flashing effect. Removing this solved the issue.

finding download box element with capybara in cucumber test

I have a link that downloads a file. As I click the link it displays dialog box with "save" and "open" option and "Cancel" and "OK" button. I want to find "OK" and "Cancel" button for cucumber test.
I took help from below link but didn't helped much.
How to test a confirm dialog with Cucumber?
**features code**
And I want to click "OK"
**steps code**
Then /^I want to click "([^\"]*)"$/ do |option|
retval = (option == "OK") ? "true" : "false"
page.evaluate_script('window.confirm = function() { return true; }')
page.click("OK")
end
The issue is that the dialogue you are talking about is not actually a part of the webpage at all. its part of the browser. Really, that part of the user interface it outside the control of the webpage.
All you can test is the webpage UP to the point of requesting the download, what the browser does with that request subsequently is not something you can script with cuke.
Sorry.

ShowWindow()...mfc

I am calling one dialog box from another.....before calling 2nd dialog box i am hiding the 1st dialog box using ShowWindow(SW_HIDE) and after finishing the operation on 2nd dialog box i destroy it....now when the control comes back to the function i am using ShowWindow(SW_SHOW) to show the 1st dialog again but it remains hidden..can anybody help me how to show it again????
EX:
Funcn(){
ShowWindow(SW_HIDE);//hide the dialog box 1st
SecondDlg var;//Class variable of 2nd dialog box
var.DoModal();//call the 2nd dialog box
ShowWindow(SW_SHOW);//after executing this statement the dialog still remains hidden...how to show it??
}
Maybe you want to call ShowWindow(SW_RESTORE) instead of SW_SHOW?

Resources