"Attempt to execute nested form events" error when calling uidoc.SelectAll() in Entering or OnFocus

In a field on a form that has the line

uidoc.SelectAll()

in the entering event (also tried moving the code to the new OnFocus event in R6, also get the error there). when I go into edit mode, this is the first field, so it automatically goes to this field, executes the entering event, selects the text in the field like should, then gives me the error “Attempt to execute nested form events”. If i comment ou this line, no error occours. This worked correctly in R5, and only occours in an R6 client. In the same database, I have other forms that execute code like this in the same manner. I am at a loss … anybody have any suggestions?

Thanks in advance!!!

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Any Postopen event code on this form?

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Yep… however the document does not automatically open in edit mode, and I do not get the error until I put the form into edit mode, and there is no code in the QueryModeChange, PostModeChange, QueryRecalc or PostRecalc subs…

Subject: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

I have the same issue. Works fine in R5 client, but in R6.0.1 CF1 client it throws the nested form event error. I do NOT have any postopen events on this form, but I do have the same uidoc.selectall() on the first field on the form.

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Did anyone come up with the solution for this problem? I get the same thing. No other form events, but this error message comes up for Notes 6 clients. Notes 5 clients do not get this error message.

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Is this with a rich text field? I’ve seen various errors with the SelectAll method in Notes 6 relating to rich text fields containing sections. I think I documented one such error in this very forum a month or two ago (fine in Notes 5, error in 6).

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Same problem over here.

No Rich Text Field, just a plain Text Field.

Problem occurs only when one switches from read to edit mode.

It does not occur when one opens the document immediately in edit mode.

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

I believe I have found a way around this. I’m not sure how helpful it will be to those of you that had the problem 3 years ago, and you may have already discovered it, but since it’s not posted here and one other person just had the problem, I thought I’d add to the list here for others.

This seems to work from read mode to edit mode as well as going directly into edit mode on a new document.

First, the field you want to select data in cannot be the first field. For some reason, the Entering event of the first field is attempting to run twice. I watched in debug as this happened. Thus, the error message. If the field you want selected needs to be the first field, you are going to need to hide a field before it. I tried doing this without the field in front, and it still gave the error. Now, you can’t hide it through the normal hide/when or it won’t work either. Also, this field cannot be computed. It must be editable. You can “hide” it by unchecking the “Show field delimiters” on the Control tab and make the text color the same as the background. The text color may not need set as you will never have anything in the field (unless you’d like to treat it like a label and have the same text in it always). But, that’s up to whatever you want. In the onFocus event of this field, you put:

document.forms[0].fieldNameToMoveTo.focus();

In the onBlur event you can do the following if you’d like to also ensure no data gets into it:

value = "";

Or, if you are using it like a label, assign the value whatever you assigned the default. But, again, nothing should ever get in the field, so you don’t have to do this part.

Next, in the field you want the data selected in, you’ll want to add the following code in the Entering event:

Sub Entering(Source As Field)

Dim ws As NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set ws = New NotesUIWorkspace

Set uidoc = ws.CurrentDocument



Call uidoc.SelectAll()

End Sub

You will still want this code in the Entering event to ensure that the data is selected other times than the initial opening of the document in edit mode. It doesn’t appear to run the first time the document opens, so it’s good to have it in there. You will also want to give initial (default) focus to this field on the Field Info tab as well. This will help a new document open with any default text selected as well.

Next, to get everything to work, you can do one of two things.

First, you can put it in your Edit button by adding the following code:

Sub Click(Source As Button)

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument



uidoc.EditMode = True



Call uidoc.GotoField("fieldNameToMoveTo")

Call uidoc.SelectAll

End Sub

This should suffice for you, or you can also do this in the Postmodechange event of the form:

Sub Postmodechange(Source As Notesuidocument)

If Source.EditMode = True Then

	Call Source.GotoField("fieldNameToMoveTo")

	Call Source.SelectAll()

End If

End Sub

Both of these things worked for me. You can even have them in the same form.

If you’d just rather use Formula in an Edit button to open the document in edit mode you need the Postmodechange event code above for sure. Otherwise, the code in the Lotusscript Edit button should do.

I believe all this only needs done if it’s the first field on the form that you wish to have data selected. If it is not, I don’t believe there is a problem. And, any other field in the document would only need the code in the Entering event.

The environment I did this in is a Notes 7 server with a 6.5.3 client.

Hope that helps others looking into this.

Thanks,

Jim

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

All,

This Error may also occur whenever you are trying to save the UIDocument twice say for Ex:

1.uidoc.save in button called Save & Close

2.Source.save in query save …

So avoid saving the uidoc twice.

Praveen

Subject: RE: “Attempt to execute nested form events” error when calling uidoc.SelectAll() in Entering or OnFocus

Most thoughtful of you to post such a well documented solution, that’s still useful at this late date! Thank you.