Calculation: Why can’t I not do this? And what should I try instead.
Why can I not do this and what should I try instead?
It would help to explain the context in which you are trying to set up this reference. And since the layout name may not always be the same as the layout's specified table occurrence (the name selected in Show Records from in layout setup...), I'd use:
Get ( LayoutTableName ) & "::FieldName"
This can be used in expressions such as:
GetField ( Get ( LayoutTableName ) & "::FieldName" ) )
Set Field By Name [ Get ( LayoutTableName ) & "::FieldName" ) ; Some value goes here to set to the field ]
Get(CurrentLayout) does not exists.
For what I understood, the calculation could be:
Get ( LayoutName ) & "::FieldName // in this case the layout name must be the same as the table name
Get ( LayoutTableName ) & "::FieldName
@Gianandrea Hi, and thanks for your reply!
Yes it is Get (LayoutName), I always get that wrong and it's CurrentLayout in my head, lol.
And thanks for this:
That's what I was looking for, but why is the " used? It seems like a very unorthodox way to use it....ok, I get it, you meant to have another " at the end.
@ Phil, thanks again for another great reply. To be honest I do not recall my implementation or where I was trying to use this. I just noted down that I couldn't do it and couldn't understand why. Now I get the rationale.
but why is the " used?
My example was:
Indirect references like this are text expressions. Thus the item to the right of & must be text. You can refer to a field name by putting it in quotes, or it can be a field, variable or calculation as long as what is used evaluates as text for the field name and with the :: to produce the correct syntax.
I try not to use quoted text for file, table occurrence or field names if this is at all possible (and it usually is possible). If you put such info in quotes like that, a change to the file name, table name, table occurrence name or field name can "break" the calculation as it then evaluates to the name of something that no longer exists.
Retrieving data ...