ktalent1 Posted March 22, 2010 Posted March 22, 2010 Hi, I created a button that activates a script to automatically import data from a text file. It does not import the entire file, but rather a select line based on another field. So, for example, if the entire text file said: Num Type 005 Cat 006 Dog and the "Pet number" field in filemaker said "005" then it would import "Cat" into the "Pet Type" field of a record that contains various info about a family's animals. However, there are cases when the "Pet number" field might say 010, which is not in the text file. When this is the case I would like to create an error message to let the user know that the pet number they entered doesn't exist. But I cannot figure out how to do that - as it is Filemaker doesn't even stay on the same "Family" record - it just goes to a blank, non-existent record and the user must relocate the family they were working on. Thanks for any help you can provide!
jamesducker Posted March 23, 2010 Posted March 23, 2010 To give a full answer, we'd need to see the whole script, really. BUT I think I understand the problem enough to suggest this. My tip would be to use a "New Window" step IMMEDIATELY BEFORE the import. This creates a duplicate of the window you are working in, and its found record(s). Do the import as usual. Immediately AFTER the import, add the following code to your script: IF get(foundcount) = 0 show custom dialog "Nothing in the text file." END IF close window If the import fails, you get a zero found count, which is what has previously forced the user to navigate back to where they started. However by doing the import in a new window, it doesn't matter if the found count ends up being 0... we close the new window and the user is put back to where they started -) Note that we close the new window whether or not the import is successful, as the user always wants to go back to where they started. We show the dialog only if the import fails. Hope that helps. James
ktalent1 Posted March 24, 2010 Author Posted March 24, 2010 Hi James, Thanks very much for your help! It now successfully returns the user to the correct screen but the error message won't display. I wonder if it has something to do with the kind of import I'm doing? I've attached a copy of the script (maybe I should have attached a copy of the actual DB???) But clearly, no worries if you don't feel like figuring this one out - you've already helped a lot. Andrew
Recommended Posts
This topic is 5357 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now