I think you may be looking for something like this:
From your client table
Set Variable (click "specify" button, lower right hand corner)
Under Name, pick name of your variable, ie ClientIdMatch.
Under Value pick TableYourOn::FieldYouWantToMatch, ie Client Table::__pkClientID
Repetition stays as 1, hit ok.
So the script will look like:
Set Variable [everything you picked will end up here]
Go To Layout [You select layout in 'specify']
Set Field [you specify Invoice::__fkClientID and for calculated result, you select your variable ($ClientIdMatch).
Attach it to a button.
Here's what the script looks like in my database. It checks to see if the customer has a related record, if it does, it goes to the related record, if it doesnt, it asks if you want to create one. If so, it goes to the correct table, opens new record, and put the key in, which populates the name field with the correct name.
I also selected the button and added this tooltip. When you roll over the button for that customer it will tell you how many related records the customer has--in my case, how many pieces of equipment.
Wow ! Thanks so much Steve for taking the time to answer. I really appreciate it. It's getting late over here in Shanghai and the brain refuses to work any more right now so I will take time to look over and study all the info you posted here tomorrow. I'll let you know how I get on. Once again thanks very much ! - Richard
Hi Steve -Thanks so much for the help and I think I have some of it understood - am I creating a 'Script' ? . Sorry that my knowledge of terminology is so limited. Also from your reply :From your client table Set Variable (click "specify" button, lower right hand corner)Where do I find the 'specify' button ? - I don't see anything like this in any any views - should this be in the Manage Database section under Layout View ? - As I can't find this option I have looked up a few things and tried to set the button as follows :To try and set the button to invoke/run a script : (is this the correct thing to do ?)Right click button in layout mode,Selected 'button set up'Selected 'Perform Script' - then on the right side 'Current Script - Pause' - then clicked 'Specify'Then in the box I selected 'New Script' and clicked the little arrow next to the + & - sign and chose 'edit'.From these options I selected 'Set Variable', 'Go to Layout', 'New Record/Request' and Set Field.Under Set Variable - I gave the name $ClientIDMatch, for Value I specified Clients::_pkClientID, and for Repetitions I chose 1Under Go to Layout I specified 'Invoice'Under New Record/Request there are no optionsUnder Set Field - I specified Invoice::__fkClientID (after which the 'specify target field box became checked). However under the 'Calculated Result' option I have no idea what to choose. I'm sorry but I don't understand the last part of your help where you state :Set Field [you specify Invoice::__fkClientID and for calculated result, you select your variable ($ClientIdMatch).I can choose as follows : Set Field[Invoice::_fkClientId; $clientID] BUT I can not find the $ClientIDMatch value anywhere under the options available when I click the 'Calculated Result' 'Specify' button .......I think I've nearly got it but at the moment when I go to browse mode and click the button Filemaker freezes and then closes after a couple of minutes.Please refer to this screen cast: http://screencast.com/t/hrNTWvi9RQIThanks very much for your patience and I hope that you can help clarify things for me - Regards: Richard
Yes you are creating a script, and attaching it to a button. I think you're just about there. The screen is freezing probably because you didnt finish the script.
I think you answered your first question about finding 'Specify'. Whenever you're creating a script, in the Edit Script box (where you're assembling the script) if there is an option to Specify, it will show up in the lower right hand corner.
You were tripped up by something that probably gets everyone at first and took me a lonnnnnnng time to figure out. A variable is not a field, so you probably wont find it anywhere.
When you select 'Set Field' in the Edit script box, it will highlight. Under 'Calculated Result' you just type in the variable (or to make sure you dont make a typo, copy and paste from the script).
That should do it. Post back if you need more help.
edit: Forgot to mention, if you have FM Pro Advanced, you can open up Script Debugger, and Data Viewer. When you run your script, you can step through each step of your script, to make sure it's working properly. and the Data Viewer will show you whats getting passed for the variable.
Fantastic - I just did it and it worked straight away ! Thank you so very much Steve - I really appreciate your help and taking the time and effort to reply to my problem. I have no idea what I could have done if it wasn't for your help and this forum. Much appreciated.
Best regards, Richard
Oh and now I can have a go at the 'Tooltip' you suggested :)
Go for it!!!
I'm still only a beginner. When it gets harder, the experts will have to help you :)
I've only been at it for a little over a year now. I would recommend the following 2 books, with their related tutorials. They really explain things rather well, and offer sample files.
FileMaker Pro 12: the missing manual. http://search.oreilly.com/?q=filemaker
FileMaker Training Series (available on this site). Now go have some frustrating, angry, let-me-try-this, almost-got-it, what-else-can-I-do.......fun!
Thanks again Steve - I'm most certainly getting the Filemaker Pro 12 : Missing Manual. Gonna carry on with the Lynda.com for a while as well. Best regards - Richard