cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a form for auto data load

Former Member
0 Kudos

How do you call a form providing it with a key field value so that the form automatically opens with the data for that key field.

Is it also possible with forms with a grid or matrix that represent a parent and child table.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

There is one more requirement for this to work and basically it is the reason the previously described problem occurs. The edit text of the key field must be enabled. This must be the case when the form is created and just before your start the find operation.

Thanks,

Mike

Former Member
0 Kudos

Here is how you disenable the key control.

Do it after you execute the "Find" by clicking the "1" button with your code. The code is below.

oItem = oForm.Items.Item("txtKeyID")

oItem.Enabled = False

Former Member
0 Kudos

Hi Mike,

You seem to have figured out alot of things about managed forms that still leave me scratching my head. I want to do the same things on a form I created with screen painter (and that is auto-managed) that you mention here.

I'm having some problems loading the data on the new form so that I can cause the find button to be clicked. No items are in the collection in AfterFormLoad or AfterFormActivate (which really isn't the right place to be doing it).

Would you mind posting the appropriate code? It would really help me out!

Thanks in advance

Former Member
0 Kudos

Hi,

It turns out that it is possible to call a UDF for auto-load of the data. Here is how to do it.

Designate that the form is auto-managed and start loading the form. After the form and its controls are fully loaded, do the following with code in the order shown.

Change the form mode to "Find".

Load the edit text of the key field with the key data.

Click the "1" button, whose caption should be "Find".

The form will load with all the data relevant to the key and the "1" button caption will be "OK".

This solution is not complete, however, because the key field ends up being editable after the data is loaded. This is problematic for two reasons: The form switches to the update mode if the data in the edit text is changed and the user is forced to click the cancel button to avoid an error.

So the last part of the solution must come from you. This is a command that will make the edit text of the key field non-editable. I know that one way to do this is to have the before click event handler for the edit text control change the bubble event to false. But this works fine until the form loses focus and then regains it. When the form regains focus the cursor is in the edit text of the key and it is editable. I can get around this by setting the bubble event to false on the before key-down event of the field unless the key pressed is the tab. However, although this works, it is not consistent with the intended look and feel of the SAP Business One user interface. The field looks editable but the user can’t edit it.

There must be a way to do this more simply. When the user does a find on a system form like the item master, the key field comes up as disabled. What command is used to do this?

Thanks,

Mike

Former Member
0 Kudos

I am openning it manually. I'm calling the form from a multi-select grid and filling in the data manually. It involves two UDTs: one is a header table and the other is a lines table.

Former Member
0 Kudos

The answer is as good as it can be. I thought the link button was going to be the offered solution, but unfortunately I need to open a UDF. So I will have to do it, the way that I'm doing it.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mike,

Unfortunately you cannot use linked buttons.

You will have to open the form by hand from an event (click on a button for example) and load your form from your code, then search for the specific key to show the correct instance.

You can use the linked button to have the yellow button, but you will have to capture the event in your code and show the form.

Regards

Trinidad.

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mike,

If you need to open B1 forms you can use the LinkButton.

You add the item LinkButton to your form and fill the key of the object, then the user only has to click on the link button.

FYI: LinkButton cannot open user defined forms.

Hope it helps

Trinidad.

Remark: Please give points to people answering your messages, specially if they help you solving your problems and mark the messages as solved once they are solved (I did it for you several times). I'm not telling you that for this message, but for all others you have already created.