Accessing the MasterField and DetailsField within a subForm macro or query

Hello,

I have a base application using a form and sub form, linked via master and slave fields and everything works flawlessly. Within the subform I have a listbox that I need to populate with a query using the master field content.

I have read / tried everything (reading APIs, writing macros, using parameters, debugging with XRAY etc.) without any tangible result.

Is there a way to access the value of the form master field from within the sub form ?

Thanks in advance.

Listbox properties, tab “Data”:
Linked field: name of this form’s field where you want to write a foreign key value.
Source type: SQL [or Query]
Source: SELECT “Text”, “ID” FROM “other table” ORDER BY “Text” ASC [or the name of a query with this statement]
Bound field: 1 [the second field having the other table’s primary key, first one would be 0]

[Example] Relations reflected by list boxes in forms

Tank you Villeroy, I use listboxes everwhere exactly as described. My requirement is to use the content of the current masterfield in the subform, either in the listbox query or somewhere else for calculations.

I have seen in the API documentation an explanation how to link forms and subforms programmatically and I wonder how to access the values from a basic macro.

https://wiki.openoffice.org/wiki/Documentation/DevGuide/Forms/Sub_Forms

Cascading listboxes:
https://forum.openoffice.org/en/forum/viewtopic.php?p=251611#p251611
https://forum.openoffice.org/en/forum/viewtopic.php?t=94393

@matteo1,
.
check out the form properties MasterFields and DetailFields.
both are string arrays.
execute this sub from a button in the sub-form.

Sub A (oEv as object)
	oSubForm = oEv.source.model.parent
	oParentForm = oSubForm.parent

	if oParentForm.isnew then exit sub

	for i = 0 to ubound(oSubForm.detailfields)
		sMasterField = oSubForm.masterfields(i)
		sDetailField = oSubForm.detailfields(i)
		oColumn = oSubForm.columns.getbyname(sDetailField)

		sTemp = sTemp & "Masterfield:  " & sMasterField & "  references  " &_
		"sDetailField:  " & sDetailField &_
		",   Value = " & oColumn.getstring & chr(10)
	next
	msgbox sTemp
End Sub

@cpb

You made my DAY ! I was able to get half of the job but I missed the important portion !

MANY THANKS !