Saúl:
Dejemos por un momento de lado el tema de las dos tablas y de la variable pública.
Lo que tenés que tener en claro es la sintaxis de ControlSource, que es la misma que utilizas para los controles Grid.
This.pgfFrame.Pagex.Text_x.ControlSource="Tabla.Campo" && entre comillas.
Pero también vale lo siguiente:
lcControlSource = "Tabla.Campo"
This.pgfFrame.Pagex.Text_x.ControlSource= lcControlSource
Ahora, si la parte de "Tabla" es una variable:
lcControlSource = lcCursor + ".Campo"
This.pgfFrame.Pagex.Text_x.ControlSource= lcControlSource ó This.pgfFrame.Pagex.Text_x.ControlSource= lcCursor + ".Campo"
Lo que no funciona es esto:
Thisform.txtTitulo.ControlSource=(pTablaConfig)+".leyenda"
Pero sí te funcionaría
.ControlSource = "&pTablaConfig..Leyenda" De donde surge reemplazar por .ControlSource = pTablaConfig+".Leyenda"
Tal vez te quede más claro con una propiedad
Supongamos:
Addproperty(thisform,"MiLeyenda", Evaluate(pTablaConfig+".leyenda") )
Thisform.Text1.ControlSource = "Thisform.MiLeyenda" && como vez, siempre es entre comillas.
Finalmente, no coincido con Ze Roberto. La expresión propuesta por Antonio no es admitida porque no es una referencia variable. En cambio, si funciona con Value.
Te muestro un ejemplo donde todo es variable (tabla y campo). El método Fill_Container crea un Container y lo rellena con objetos label, Textbox y Checkbox, con algunas simplificaciones. Se evitan aquí los campos Memo, solamente porque la inserción de un EditBox complica un poco la distribución de cuadros. Pero lo que te interesa aquí son los ControlSource.
En este código hay alguna redundancia en cuanto al array lafields() y variables como lcName, lcType, etc, pero es solamente para mayor claridad del código.
Ah, este Evl(tcCursor , "CLIENTES") es solamente por comodidad [ Thisform.fill_container() ]
* Método Fill_Container
LPARAMETERS tcCursor
tcCursor = EVL(tcCursor,"CLIENTES")
LOCAL lnTop,;
lnLeft,;
lnHeight,;
lnMaxWidth,;
i,;
lnfields,;
lcName,;
lctype,;
lcCampo
This.NewObject("cnt_Per","Container")
WITH This.cnt_per
.top = 1
.left = 1
.Width = This.Width - 2
.Height = This.Height - 2
.backcolor = RGB(220,228,224)
.Visible = .t.
ENDWITH
lnTop = 5
lnLeft = 100
lnHeight = 20
lnMaxWidth = 0
SELECT (tcCursor)
lnfields = AFIELDS(laFields,tcCursor)
FOR i=1 TO lnFields
lcName="Text"+TRANSFORM(i)
lcCampo = laFields[i,1]
lcType = lafields[i,2]
IF lcType ="M"
LOOP
ENDIF
lnWidth = ICASE(lcType="D",62,LcType="L",20,(lafields[i,3]+laFields[i,4])*6.5)
lcBaseClass = IIF(lctype="L","Checkbox","Textbox")
lcName = IIF(lcType = "L" ,"Check" , "Text")+TRANSFORM(i)
lcLabel = "lbl_"+lcCampo
IF !PEMSTATUS(This.cnt_per,lcLabel,5)
This.cnt_per.newobject(lcLabel,"Label")
ENDIF
WITH This.cnt_Per.&lcLabel
.Caption = PROPER(lcCampo)
.top = lnTop + 3
.Left = lnLeft - 90
.FontSize = 8
.Height = 17
.BackStyle = 0
.Width = 88
.visible = .t.
ENDWITH
IF !PEMSTATUS(This.cnt_per,lcName,5)
This.cnt_per.newobject(lcName,lcBaseClass)
ENDIF
WITH This.cnt_Per.&lcName
.left = m.lnLeft
.top = m.lntop
.Height = m.lnHeight
.Width = MAX(m.lnWidth , 20 )
.Fontsize = 8
.ControlSource = tcCursor+"."+lcCampo
IF lcBaseClass == "Checkbox"
.caption = ""
.backstyle = 0
ENDIF
.visible = .t.
ENDWITH
lnMaxWidth = MAX(lnMaxWidth , lnWidth)
lnTop = m.lntop + m.lnHeight
IF (lnTop + lnHeight + 4) > This.cnt_per.Height
lnLeft = lnLeft + lnMaxWidth + 110
lntop = 5
lnMaxWidth = 0
ENDIF
NEXT
lnMaxWidth = 0
FOR EACH ocontrol IN this.cnt_per.controls
lnMaxWidth = MAX(m.lnMaxWidth , ocontrol.left + ocontrol.Width )
ENDFOR
This.cnt_per.Width = lnMaxWidth + 2
This.Width = This.cnt_Per.Width + 1