Give Field Initial (Default) Focus - not working

I tried to post this earlier, but it hasn’t ever shown up…

I have a Shared Action in a view that prompts the user for a piece of information. It then creates a new document and populates a field with the user information. This works fine.

I’d like to place the cursor in the first field so the user can enter additional data so I chose ‘Give Field Initial (Default) Focus’ in that field’s properties. BTW, the initial field is inside a table (if that matters).

The new document is opened in edit mode. But the cursor isn’t in any of the fields.

Any ideas?

Here is the code from the action button:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim workspace As New NotesUIWorkspace

Dim askme As Variant

Dim uidoc As NotesUIDocument

Set db = session.CurrentDatabase

Set doc = db.CreateDocument

askme = workspace.Prompt(PROMPT_OKCANCELEDIT, “Enter Grid”, “Enter the Grid # in the box below:”)

doc.BaseGrid = askme

Call doc.Save( True, True )

Set uidoc = workspace.EditDocument(True, Doc)

End Sub

Subject: Give Field Initial (Default) Focus - not working

Try adding something like this to postopen of your form:

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Call UIDoc.GotoField(“YourFieldName”)

Subject: RE: Give Field Initial (Default) Focus - not working

Tom & Raphael,Thank you both for your ideas! It certainly is nice that those with more experience take the time to help the rest of us.

Unfortunately, I had tried these and was unsuccessful. Both ways, I get the error ‘Document command is not available’ on the Call to GoToField.

Maybe it’s the doc.save?

Thanks again!

Subject: duplicate post - delete

Subject: RE: Give Field Initial (Default) Focus - not working

I have seen a bug using this when the debugger is turned on. Does it work when you turn off the debugger?

The document also needs to be in edit mode prior to calling it. Something like:

If UIDoc.EditMode then

Call UIDoc.GotoField(“YourField”)

End If

Subject: and the field also needs to be Editable

Subject: RE: Give Field Initial (Default) Focus - not working

Hi Tom,The debugger isn’t on, the document is in edit mode, and the field is editable. When I add your IF statement to the action, I don’t get an error, but I don’t get the field focus either.

It must be Monday again. Thanks so much for your interest,

E

Subject: RE: Give Field Initial (Default) Focus - not working

My earlier post mentioned to add it to the postopen event of the form, not the action itselft. Try it in that event.

Ah ha, you must have had the day off yesterday for prez day - today is actually Tuesday - however it does feel like a Monday.

Subject: RE: Give Field Initial (Default) Focus - not working

No error received, but no cursor either. This seems like such a simple thing…Thanks again for trying to help.

BTW - Some weeks, every day seems like a Monday - no holidays between MLK and Mem Day here.

Subject: Give Field Initial (Default) Focus - not working

Hi Elli,

Associate form with Doc and then open the Doc in UI. e.g.

Set doc = db.CreateDocument

askme = workspace.Prompt(PROMPT_OKCANCELEDIT, “Enter Grid”, “Enter the Grid # in the box below:”)

doc.BaseGrid = askme

Doc.form = “FormNameHERE”

Call doc.Save( True, True )

Set uidoc = workspace.EditDocument(True, Doc)

You haven’t associated a form with Document and that can be a reason for this behaviour.

Hope this helps.

Best Regards,

Munish Kaushik

Subject: Give Field Initial (Default) Focus - not working

Elli,

As an experiment, make another button that just does an @Command([Compose]) and see if the default focus is correct. If so, then it’s because you have already created/saved the document and are programmatically going into edit mode.

But the solution in that case is simply to add a line such as

call uidoc.gotofield ( “SomeFieldName” )

regards,

raphael

Subject: RE: Give Field Initial (Default) Focus - not working

Raphael,Thanks for your insight!

I tried your experiment suggestion. It does NOT set the focus on the first field either.

Any idea why?

Subject: RE: Give Field Initial (Default) Focus - not working

Sometimes, the code in the form events might get corrupt and may not execute properly. Hence remove the code from those Form events(form with which you are editing the doc) and copy in a notepad. Save the form. Now copy and paste the same code into the corresponding form events back from notepad. Try composing the form again from that view action button.

If still do not work/ if you have no such code in form events refresh the document after open,

Try putting

Call Source.Refresh

Call Source.GotoField(“YourField”)

or

If you have any hidewhen’s for the fields’

Call Source.RefreshHideFormulas

Call Source.GotoField(“YourField”)

in the “onload” event of the “form” with which you are trying to open the created document. Your code do not specify any form name like doc.Form = “so&so”. Hence I am assuming that you are using the “Default” form of the database.

Please post your comments after your try.