cancel
Showing results for 
Search instead for 
Did you mean: 

Setting focus to a field after form load

Former Member
0 Kudos

Hi all,

SBO 6.50.097 SP:01 EF:07

Just a small query, is there a way to set focus to a field as soon as a form has loaded?

For example: when the Stock Transfer screen (FormType = 940) loads, it sets the focus to the From Warehouse field (ItemUID = "18"). Is there a way to set the focus to the Customer field (ItemUID = "3") after the form is loaded?

I can use the following code to select an EditText type item object:

'Customer field.

Set oItem = oForm.Items.Item("3")

oItem.Click ct_Regular

but this does not work with et_Form_Load etc.

Any help is much appreciated.

Regards,

Andrew.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You might be able to use the form load event for this.

Simulate a user click "after" the action has taken place.

if pval.eventtype= et_FORM_LOAD

_ and pval.beforeaction = false then

end if

This should give you a sort of "form loaded -event". If SAP generates before and after action in this case.

HTH Lutz Morrien

Former Member
0 Kudos

Hello,

Thank you for the reply!

The pVal.BeforeAction property you mention only seems to work with a MenuEvent object. For an ItemEvent object the pVal.Before_Action property only specifies if the event was was issued before or after SBO handles the event. If I use the following code:

If pVal.FormType = 940 And pVal.EventType = et_FORM_LOAD Then

If pVal.Before_Action = True Then

SBO_Application.MessageBox "Hello"

End If

End If

nothing happens. Whereas if I use the following code:

If pVal.FormType = 940 And pVal.EventType = et_FORM_LOAD Then

If pVal.Before_Action = False Then

SBO_Application.MessageBox "Hello"

End If

End If

or

If pVal.FormType = 940 And pVal.EventType = et_FORM_LOAD Then

SBO_Application.MessageBox "Hello"

End If

then the messagebox appears before the form loads. So my code is being executed before the form is loaded - I need it to execute after the form loads.

Regards,

Andrew.

Former Member
0 Kudos

Hi Andrew,

within the working code , the event does translate to "after form_load".

(Form_load Event + before_action=false)

But that obviously does not help you since your code still does not work. Maybe using another event would (like form_activate).

HTH Lutz Morrien