[WD21] Unexpected behaviour

Startbeitrag von David Egan am 22.12.2016 04:57

Hi
I have a form which is called from another window which contains a table. The form can be called from a couple of different windows, both of which have similar tables.

The following code works to update the calling table:

TableDisplay(frmBusinessPartner.Table_Contacts,taCurrentSelection)

The following throws an error: a control has no subelement: "." operator not allowed

TableName = "frmBusinessPartner.Table_Contacts"
TableDisplay(TableName,taCurrentSelection)
I didn't think that I would need indirection for this but this also fails with the same error.

TableName = "frmBusinessPartner.Table_Contacts"
TableDisplay({TableName,indcontrol},taCurrentSelection)
I've wasted hours on this & just don't understand why it works when the table is explicitly named but not with a variable. Can anyone explain what the problem is please & why it doesn't work as I expect

Thanks

David

Antworten:

Hi David,

Assuming that frmBusinessPartner is a window.
I'm used to call a window with a form where the form returns a result true or false and then if true update the table in the calling window itself.
That way your form window does not need to update elements from windows that are not open at compile time.

Regards,
Piet

von Piet van Zanten - am 23.12.2016 09:05
Hi David
Quote
David
I have a form which is called from another window which contains a table. The form can be called from a couple of different windows, both of which have similar tables.


This is not verry cleat to me. To me thare are:
1 windows
2 forms ( window conting several fields of 0ne record is a form )
3 windows with a table

In the table read what the record is . ithis record needs to be displayed in the form ( window with lots of edit controls witch together form a "FORM".

Open the window and add the nessisary parameters to this proces so you can open the form with the ID that your table row has.

Hope this helps. Otherwise look at the rad code of windev. this generated code might give you some pointers.

if you ask a question be as specific as you can . Then we can give you a specific as possible answer as well.
The way you talk about forms, windows and forms that contain tables is not helping;)


regards

Allard

von Allard - am 27.12.2016 16:39
Hi David,

I am on the same lines as Piet; I update the table in the calling table window itself, when coming back from the form window.

But if you must do it the way you do, you could try saving the caller window's name when coming to the form window, like:

sCaller is string = CurrentWin() //Do this in the window's global declarations to get it right

and then, when you have done your deed and need to update the calling window's table, first test which window was the caller, and code accordingly, like:

Switch sCaller
Case "frmBusinessPartner": TableDisplay( frmBusinessPartner.Table_Contacts, taCurrentSelection)
Case "frmPersonalPartner": TableDisplay( frmPersonalPartner.Table_Contacts, taCurrentSelection)
END

The fact that variables do not always work as expected, is just one of the little quirks WD has...
Best regards
Ola

von Ola - am 28.12.2016 13:18
Hi David,

I would agree with Piet & Ola that the correct method is to update the table from within the window containing the table control.

However if you wish/need to continue as is then I believe you will indeed need to use indirection.
Change your code to
TableDisplay({"frmBusinessPartner.Table_Contacts",indWindow},taCurrentSelection)

and it will, I believe, do the job.

von DerekT - am 29.12.2016 10:48
Thanks everyone, I think I'll change the logic as generally suggested.

Cheers

David

von David Egan - am 29.12.2016 18:57
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.