In article
, Katie
Blake wrote:
> What on earth am I doing wrong? Thanks to various posts here over the
> years, I have been experimenting with using a self-join to populate a
> portal with ONLY contact names starting with a specific letter. This
> is what I have done:
>
> Designed a new database with only one table, and three fields - Name,
> Calc, and Filter.
>
> Name is a text field with surnames
> Calc is a global field which calculates the first letter of each name
> using Left (Name ; 1) This works perfectly
> Filter is a text field which uses a value list of each letter of the
> alphabet.
Hopefully that's a typo. If Calc is actually a Global field, then it will
only ever calculate as the first character of the first record.
Calc would usually be a normal Calculation field, not a Global field (but
see below) and Filter should be the Global field.
The reason is so that the user can pick a letter from the Filter value
list, which is then matched to the appropriate records with that same data
in their Calc field.
i.e.
rel_ChosenLetter
Match records in TableA with records in TableA
when Filter = TableA::Calc
The on the Layout you can have the Filter field set to display the Value
List (normall as a pop-up menu or drop-down list so it uses up less screen
space).
Also make sure the Portal contains fields via the same Relationship.
BUT,
unfortunately there's a hiccup here - you can't have a Calculation field
on the right hand side of a Relationship since it can't be indexed (this
may depend on what version of FileMaker you're using). That means the Calc
field must instead be a normal Text field which uses an auto-enter
calculation to obtain the result, but only once data has been entered into
the Name field - the options for an auto-enter calculation are meant to do
this, but are a bit flakey, so it's usually best to do it yourself.
e.g.
Calc Text
auto-enter by calculation:
If(IsEmpty(Name); ""; Left(Name;1))
This way Calc remains empty while Name is empty, and FileMaker will
perform the auto-enter calculation once Name has data entered into it.
(Normally FileMaker will perform auto-enter options when the record is
created.)
This then causes a second problem - because Calc is a normal Text field,
this also means that when the data is changed in the Name field, the Calc
data will need to be changed either manually or via a script.
What I normally do in similar situations is create another field called
OldName which is a normal Text field with an auto-enter calculation to
copy the data from Name (again, only after it actually has some data).
e.g.
OldName Text
auto-enter by calculation:
If(IsEmpty(Name); ""; Name)
Then you can have a Calculation field that checks to see if both Name and
OldName contain the same data ... if not the field can display a warning
(either tect of graphically).
e.g.
ChangedName Calculation, Text Result, Unstored
= If(Name = OldName; ""; "Name has been changed!")
Put that field on the Layout next to Name, and it can be set as a button
to run a Script that updates the neccessary fields (OldName is given a new
copy of the Name data, and Calc is given the new first letter).
e.g.
Set Field [OldName; Name]
Set Field [Calc; Left(Name; 1)]
The warning will reset itself once the Name and OldName have the same data.
Helpful Harry

)
>> Stay informed about: Alphabetic pick list using self join and portal