Jump to content
Sign in to follow this  
Addam

Is ther a way too...

Recommended Posts

I have 2 databases...

I need to be able to perform a find in one and perform that same find in another database as well in 1 step... I'm sure this might have to be scripted, but I'm totally in the dark on how to complete this.

I'm doing this because 1 database has a set of fields and the other has a few of the same fields, but a totally different set fields of it's own.

Share this post


Link to post
Share on other sites

There are a couple of ways to approach this, depending on the outcome you are looking for and the content of the two databases, however the most obvious one is to script the whole find sequence for both files.

To do this, create a 'Find Criteria' layout in your main file, and populate it with global fields into which users can enter their find criteria.

Next create a relationship between the two files which is based on a calculating constant field (eg formula = '1').

Finally, create a 'find' script in the main file which clears the global fields, takes the user to the 'find criteria' layout to enter their request, then enters find mode and transfers the global field contents to the corresponding fields before performing the find. Finally, the find script should make a call to an external script in the second file.

The external script in the second file should enter find mode, retrieve the find criteria from the global fields in the first file (via the constant relationship) to populate a find request within the second file, perform the find and then return the user to the first file (by calling a script in the first file which has only the single step "Refresh [bring to front]".

You might want to consider creating an alternate version of the script in the main file called 'Modify last find, which omits the starting steps that clear the global fields (in all other respects, this script will be the same as the 'find' script).

You will then want to consider what steps might be desirable in order to guide users (via the interface and/or access privileges) to performing their finds via your find script rather than manually.

Share this post


Link to post
Share on other sites

As I recall (from a previous job) the above solution always worked in FMP3, and sometimes failed in FMP4. I'm not sure whether it works again in FMP5. The problem was that relationships to a global field didn't work when you have zero records showing in your database. You might want to check this situation out.

I developed plugins to resolve this situation, but they are quite "techy". If you are new to scripting, give them a miss. If not, you can check out http://www.jazzmedia.com.au/shareware.html The simpler solution uses 'Jazz Globals' to save and retrieve values between scripts in different databases. The more complex (but more elegant) solution is to pass parameters between your scripts, using 'Jazz Params'. If you don't understand how these would help, I'm afraid the plugins aren't for you.

Plugin solution aside, make sure you check out the relationship issue in FMP5 or 6 or whatever you are using.

Cheers,

John

Share this post


Link to post
Share on other sites

Hello John,

I agree that there are some versions of FMP in which the procedure I suggested won't work if there are no records in one of the databases.

The use of external functions as an alternative is an option and, though I confess I've not worked with Jazz Params, I've used a plug-in from 24u which provides 'global values' functions, to good effect for similar purposes.

Another approach which doesn't require a plug-in, but is perhaps equally complex to script, is the use of a third file as a dedicated repository for the global values.

However in this particular instance, I'm suspect that the extra effort is not warranted, because if there are no records in one of the files, then the matching 'find' procedure will also not produce a useful result, and a single, manual find in whichever file has some content would suffice.

If there is a possibility that the script will be launched at a time when there are no records in one of the files, a simpler solution would be to test for this (eg using an "IsValid( )" function call to a mandatory field in each file) and abort the script with an appropriate feedback message to the user if either of the tests failed.

Share this post


Link to post
Share on other sites

Can this 'find in multiple files' be done if the fields being searched on are different?

A simple example might be -- a 'student' database (studentID, name, address) and a 'studentGender' database (which has only studentID and studentGender fields) joined by 'studentID'. Is it possible to search for M or F in the 'studentGender' db and extend the found set to the student database searching for the matching studentIDs?

In other words, can you find the boys/girls in the 'studentGender' db and then return to the 'student' db and only see the boys/girls?

Thanks for your help.

Abbe Lougee

OSU/The SMILE Program

Share this post


Link to post
Share on other sites

Hello Abbe,

The answer is a qualified yes.

A scripted find procedure in both files is possible, but only insofar as the fields that criteria are entered into are present (and hold valid data) in both files. If your special 'find' layout was restricted to fields which were present and valid in both files then, on the face of it, the procedure should work.

A further consideration, is that given that the files are different, there is then no guarantee that the same group of students will be present in the two found sets - eg if records have been deleted or added to one file but not to the other.

Depending on the purpose for which you're contemplating using this procedure, there may be other ways to approach it.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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