Suzanne Posted June 24, 2002 Share Posted June 24, 2002 I'm not familiar with macros so the scripting confuses me a bit. I want to jump to another database to the related record number. I am able to do that if a record with that number has already been created in the database I am jumping to. The problem is in many cases the record for the database I am jumping to has not been created. So when the script is run I end up in the database with all fields blank because there is no related record. I think what I need is an if then script. I need the script to go into the new database look for the number and if the number does not exist within that database I need a message to come back to the user telling them that the number cannot be found. I appreciate all the help from the cafe. I like to figure things out on my own but this is so new to me. I just got the book " Scriptology FileMaker Pro Demystified". Untill I understand a bit more of the book I need a little help from you guys. Thanks alot. :rolleyes: Quote Link to comment Share on other sites More sharing options...
andygaunt Posted June 24, 2002 Share Posted June 24, 2002 Hi Suzanne, You have a relationship from recordnumber::recordnumber and I take it this is a serial number. OK. What you will need in your If script is something along the following lines. If ["IsValid(Relationship::recordnumber field) Go To Related Record Else Show message [with just an ok button] "We do not have a matching record in the second database. Sorry" Exit Script End If Basically what this will do is check the related database to see if a match can be found. This uses your relationship to that database and the field record number. If a match is found this determines a true or 1 value and so will go to that related record. If one is not found, this determines a false or 0 valueand will then show your message. HTH Quote Link to comment Share on other sites More sharing options...
Suzanne Posted June 24, 2002 Author Share Posted June 24, 2002 It's not working. I'm testing it with a known matching file in the other database. I get the message box that sais there is no file that matches. And it will then open the other database with the last file opened in the database. Suzanne :eek: Quote Link to comment Share on other sites More sharing options...
andygaunt Posted June 25, 2002 Share Posted June 25, 2002 Suzanne, can you send the files over and I will have a look at for you. By rights it should work. Quote Link to comment Share on other sites More sharing options...
Suzanne Posted June 25, 2002 Author Share Posted June 25, 2002 I did something different. The only problem I see is when it doesn't find the record number it brings me into the other database with another record number, I want to stay in the current database. NOT EQUAL: does mean not equal to? I didn't see anything with and = and a / through it so I used it. This is what I did: If["BusDesID=HrsBRtoID::HrsID"] Go to Related Record[HrsBRtoID"] Else If["BusDesIDHrsBRtoID::HrsID"] End if Show Message["Bla Bla"] Exit Script End if Something is missing. Thanks Quote Link to comment Share on other sites More sharing options...
Suzanne Posted June 25, 2002 Author Share Posted June 25, 2002 It is working the way I did it. I was using that script as a subscipt and it was the end of the first script that was bringing me into the other database. Is the script ok the way I did it or would it be better the way you are suggesting? If it's better the way you are suggesting I will send you my files. Suzanne Quote Link to comment Share on other sites More sharing options...
andygaunt Posted June 25, 2002 Share Posted June 25, 2002 Suzanne, The way I suggested with the IsValid step is basically your way without the if it is or isnt and it should work. I cant see why it does not. Try adding on the go to related record the show only related option. If ["IsValid(HrsBRtoID::HrsID) Go To Related Record [show only related] Else Show message [with just an ok button] "We do not have a matching record in the second database. Sorry" Exit Script End If This should work, and the benefit of it is it works based on the relationship and the field you select (in this case HrsID). It returns a boolean value making it very quick to see if there are any records in the related database. If you want you can send me the files to quickly look at. Quote Link to comment Share on other sites More sharing options...
dj Posted June 25, 2002 Share Posted June 25, 2002 Sorry for jumping in, but I would not use undocumented behaviour of isValid function. Officially, isValid(relName::fieldName) "returns 0 if the related file was renamed and the relationship is not updated with the new file name" Instead I'd use something like this Set error Capture [on] Go to Related Record[relName] If [ Status(CurrentError)=101] Show Message //no rel records else Go to Related Record[relName, show only related] end if Dj Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.