Forum Discussion

ScottPugh's avatar
ScottPugh
Qrew Cadet
6 years ago

Setting a 'Primary' address- How to ensure only 1 child record has a checkbox checked

I have a location table with a relationship to an Address table.   Each location can have many addresses.  I'd like to add a checkbox to the address table called 'Primary'.  The purpose of this field is to identify the primary address of the location.    As such I would need to ensure that only 1 child address of a location can have the 'primary' checkbox checked at a time.


How can I accomplish this in QB?

2 Replies

  • Since you have a direct relationship between Locations and addresses - the easiest way is to summarize the # of Addresses records where that box is checked into your location table through regular summary fields. Then - do a lookup of that field back into your address table. With that new counter - you can set up form rules or automations to uncheck any addresses that get flagged once you already have a primary address checked off.



    Chayce Duncan | Technical Lead
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base
  • You can set up a formula text field and set it to be unique in Field Properties.

    The field should be called [You must only select 1 Primary Address].  You will see why I say that when you test.

    The formula would be

    IF([Primary?]=true, ToText([Related Location))

    The effect will be that non Primary addresses will calculate to null, where duplicates nulls are in fact allowed for a field set to be unique.  But if Primary then only 1 will be allowed.  It's quick to set up and test the user experience.