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:”)
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,
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
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.