Jump to content

Relationship based on Field Name


This topic is 7161 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have 2 tables in my file.

Table1 has fields like "Title", "Creator", "Type" and "Description".

Table2 has 2 fields, "fieldName" and "fieldDescription". The values in "fieldName" match the Field Names in Table1.

What I want to happen is when the cursor moves into a field in Table1, the description that goes along with that field is displayed in "Description". So, I want to look for the record in Table2 that has the name of the active field in Table1 and put the value in "fieldDescription" in Table1's "Description" field.

Why don't I just use the FieldComment() function? Because there is more than one line of text in the descriptions.

Sorry if this is a complete newbie question, but I can't seem to wrap my brain around it.

Thank you for any hints/suggestions you can give.

Link to comment
Share on other sites

You can do this with a script if you use the Get(ActiveFieldName) function to set a global in Table 1, then have a relationship between Table1:gActiveFieldName and Table2:fieldName. You can then show the related fieldDescription on the layout.

Because the Get(ActiveFieldName) only evaluates correctly during scripts, you can't use it directly to create the relationship.

Link to comment
Share on other sites

I set a field in Table1 - gActiveFieldName as Text, Global Storage.

I create a script "setActiveFieldName" with one step "Set Field[table1::gActiveFieldName; Get ( ActiveFieldName)]

I run that script when I open the file (B)?)

I open up "File --> Define --> Database --> Relationships" and drag a line from 'gActiveFieldName" in Table1 to 'FieldName' in Table2.

On my layout in Table1, I put a field "::FieldDescription" from Table2.

I reopen my file.

I see nothing in 'gActiveFieldName" or "::FieldDescription" on my layout as I tab through the fields. Please forgive my obvious lack of FM skill and give me a few more hints. :-)

Thank you!

Link to comment
Share on other sites

This topic is 7161 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.