Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need help with using a related table in a calculated field

Featured Replies

You have to forgive me, but I'm not very good with filemaker. I have 2 tables in my database. One has customer information, and the other has phone numbers. I have it set up so that the company table is related to the phone table by a unique customer ID. It's set up that way so companies can have multiple phone numbers and not have just 2 static phone/fax fields in the customer table. Here's what I mean:

Customer table:

custno custname

1 "Customer 1"

2 "Customer 2"

Phone Table:

PhNo custno number type

1 1 555-1212 "phone"

2 1 555-2121 "fax"

3 1 555-3232 "pager"

4 2 555-2323 "cell"

My question is, how can I create a calculated field in the company table that can merge the first 2 phone records into 1 field. Somthing like this:

Modified Customer table:

custno custname combined

1 "Customer 1" "555-1212, 555-2121"

2 "Customer 2" "555-3232, (blank)"

What functions if any can pull the two related records into one field? And what would the final calculation look like?

I hope that makes sense, Thanks for your help.

Hmmm, enter GetNthRecord function :)

The calculation would reside in your Customer Table. We'll call our field cTwoNumbers.

Now, the GetNthRecord function is a function that is new to filemaker 8. Normally when you call a related field through a calculation, you will retrieve only the first record. GetNthRecord(RelatedField;RelatedRecordNumber) however can retrieve the field contents of any particular related record number.

Assuming your table accurance names are the same as your table names, your calculation could take the form of the following:

Case(

Count(Phone Table::custNo)= 0 ; "(blank), (blank))";

Count(Phone Table::custNo)= 1 ; Phone Table::Number & ", " & "(blank)" ;

Phone Table::Number & ", " & GetNthRecord(Phone Table::Number ; 2)

)

you could also use ifempty checks instead of counts but ... meh.

~Genx

Edited by Guest
syntax

  • Author

Thanks Genx!!

Just tried it. It works great. It's fortunate for me that this database is starting it's life in FM8. All of our old databases are still in FM6.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.