dbTalk Databases Forums  

Check for specific child record

comp.databases.filemaker comp.databases.filemaker


Discuss Check for specific child record in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Check for specific child record - 12-26-2009 , 10:59 AM






This is pretty basic, and I've alredy solved it, but I wonder if things
are even simpler.

In FMP 10, I need to find you whether the present record has a specific
keyword assigned, i.e. if there's a child record with a specific foreign
key (a different table's key, I'm looking into a join table here).

I could create a calculated field that holds this key and use it in a
relationship, then I could use IsValid.

Without the additional field and relation, I use this:

FilterElements (

List ( ChildTable::ForeignKey ) ; // List of all foreign keys

"44" ) // the hard coded value I'm looking for

= "44¶" // See if this returns right or false (mind the return)

Apart from the hard coded value, which could of course be mended - is
this the best way to find out?
--
http://clk.ch

Reply With Quote
  #2  
Old   
Lynn Allen
 
Posts: n/a

Default Re: Check for specific child recordX-TraceApproved - 12-26-2009 , 11:17 AM






On 2009-12-26 08:59:10 -0800, clk (AT) tele2 (DOT) ch (Christoph Kaufmann) said:

Quote:
This is pretty basic, and I've alredy solved it, but I wonder if things
are even simpler.

In FMP 10, I need to find you whether the present record has a specific
keyword assigned, i.e. if there's a child record with a specific foreign
key (a different table's key, I'm looking into a join table here).

I could create a calculated field that holds this key and use it in a
relationship, then I could use IsValid.

Without the additional field and relation, I use this:

FilterElements (

List ( ChildTable::ForeignKey ) ; // List of all foreign keys

"44" ) // the hard coded value I'm looking for

= "44¶" // See if this returns right or false (mind the return)

Apart from the hard coded value, which could of course be mended - is
this the best way to find out?
Hmmm. Although this works, I wonder about the processing time,
particularly if the list of child values might grow long.

Personally, I would create another relationship in the parent file.
This would be a compound relationship. In the parent, create a global
to hold your specific value. Then the relationship becomes:

ValueGlobal = ForeignKey AND
ParentKey = ParentKey

You can instantly check, using IsEmpty(KeyField), whether or not this
child record exists. Don't use IsValid to check for existing records,
that's not what it's intended for and it will fail under certain
circumstances.

The advantage of this, is that if you ever need to check on a different
key word, you can populate the global with whatever you want. And the
IsEmpty test is extremely fast.
--
Lynn Allen
--
www.semiotics.com
Member FBA
FM 10 Certified Developer

Reply With Quote
  #3  
Old   
Ursus
 
Posts: n/a

Default Re: Check for specific child record - 12-27-2009 , 03:39 AM



I don't know about better methods, but it seems to me there's one bug in
your code.

What if the value you are looking for comes last in the List? I seem to
remember it wouldn't be followed by a pilcrow and the calc would return a
false.

--
Keep well / Hou je goed

Ursus


"Christoph Kaufmann" <clk (AT) tele2 (DOT) ch> schreef in bericht
news:1jbceft.znrh571qp0i1yN%clk (AT) tele2 (DOT) ch...
Quote:
This is pretty basic, and I've alredy solved it, but I wonder if things
are even simpler.

In FMP 10, I need to find you whether the present record has a specific
keyword assigned, i.e. if there's a child record with a specific foreign
key (a different table's key, I'm looking into a join table here).

I could create a calculated field that holds this key and use it in a
relationship, then I could use IsValid.

Without the additional field and relation, I use this:

FilterElements (

List ( ChildTable::ForeignKey ) ; // List of all foreign keys

"44" ) // the hard coded value I'm looking for

= "44¶" // See if this returns right or false (mind the return)

Apart from the hard coded value, which could of course be mended - is
this the best way to find out?
--
http://clk.ch

Reply With Quote
  #4  
Old   
Christoph Kaufmann
 
Posts: n/a

Default Re: Check for specific child record - 12-27-2009 , 05:56 AM



Ursus <ursus.kirk (AT) ziggo (DOT) nl> wrote:

[using filterelements ( list ( ChildTable::ForeignKey ) ; 45 ) = "45¶"]

Quote:
What if the value you are looking for comes last in the List? I seem to
remember it wouldn't be followed by a pilcrow and the calc would return a
false.
I tested that and found out it's the other way round: Even with the
value 45 coming last, the calc returns correct if I for "45¶", but false
if I ask for "45" or 45.

--
http://clk.ch

Reply With Quote
  #5  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Check for specific child record - 12-30-2009 , 04:23 PM



Christoph Kaufmann wrote:
Quote:
This is pretty basic, and I've alredy solved it, but I wonder if things
are even simpler.

In FMP 10, I need to find you whether the present record has a specific
keyword assigned, i.e. if there's a child record with a specific foreign
key (a different table's key, I'm looking into a join table here).

I could create a calculated field that holds this key and use it in a
relationship, then I could use IsValid.

Without the additional field and relation, I use this:

FilterElements (

List ( ChildTable::ForeignKey ) ; // List of all foreign keys

"44" ) // the hard coded value I'm looking for

= "44¶" // See if this returns right or false (mind the return)

Apart from the hard coded value, which could of course be mended - is
this the best way to find out?

What you have is probably fine. But you can accomplish the same thing
without the custom function, as:

patterncount(
¶ & List ( ChildTable::ForeignKey ) & ¶;
¶ & "44" & ¶
)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.