You may also recall a suggestion to use a portal to payments to log payments made by a student instead of this script.
You need to enter or select matching data in the studentID field in the payments table before it is linked to a student record. The script used could be modified to do that automatically if you wanted to use that button only for adding new payments, but then you can't click the button just to see the last payment record.
With a portal, and "allow creation of records via this relationship" enabled, you can add a new payment directly in the protal and FileMaker will update the StudentID field for you to link the new record to the current student.
Here's a modification that can set this up to work with your current script:
Before the Go To Related Records step, add this:
Set Variable [$$StudentID ; StudentInfo::StudentIDPK]
Then, Open manage | database | fields and find the Student_Payments::StudentIDFK field. Double click it to bring up field options.
Click the auto-enter tab and select the calculation option. Enter $$StudentID as the auto-enter calculation.
Now, your script sets this global variable, $$StudentID to the value of the current student. And now any new student_payment records will automatically enter this value into the FK field of the payments table.
Please note the following issue, however: If you navigate to a layout for Student_Payment by any other means, the $$StudentID variable is not updated and a new payment record might then leave the StudentIDfk field blank or even enter the ID number of a different student--linking it to the wrong student.
It is possible to use an OnRecordLoad script trigger to run the above step as a one line script. If you set that up on every layout based on Student_Info, you can leave the step out of your current "go to payments" script and you'll eliminate the chance that you might accidentally link the payment record to the wrong student.
It's also possible to set up StudentIDFK as a drop down list of StudentID's with a name field listed along with the ID's. Then you can create a new payment record and select the appropriate student from this drop down.
I'm not sure I follow part of this.
First I'm assuming that when you say "using a portal to make payments" , I assume you mean on the student info layout?
And when you give the modification to the current script to "set this up to work with your current script:", are you changing concepts and going back to how I have it now and the mod's suggested would continue on with the way I have things setup now (switching back and forth by the student and payment buttons)?
Yes, the portal would be placed on a student info layout.
Yes, I changed concepts on you. I actually listed 4 different options. You can use any one of them or even a combination of them:
- Use the portal
- Modify your current script by adding the set variable step and the auto-enter field option on the fk field.
- Put the set variable step in it's own script performed by OnRecordLoad on every student layout (and use the same auto-enter setup as #2)
- Use a drop down list to select the student to which to link your payment record
As an added precaution, you might add name fields from student Info to your payment layout. If these fields are blank, your payment record is not linked to a student record. They'll also serve as a warning if your payment record should be linked to the wrong student.
I just added the modifcation to the script and then did the changes down to setting $$StudentID as auto-enter calc and when I add a payment record and return to student info layout the portal doesn't show anything.
It'll work, I've used this method myself. I can't tell from your post what detail you may have left out. You can post your script or share the file...
If you are using FileMaker 11, put this layout text on both layouts: <$$StudentID>> so you can see if the variable is getting a value as expected.
To post a script to the forum:
- You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
- You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
- If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
- If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)
Hmm, I remember spotting that StudentIDFK was defined to auto-enter a serial number and told you to remove this setting. Did you remove it?
It will keep your payment records disconnected by entering values that don't match to the current student.
Some times it's the little things. If there are no related records, the script goes to the payment layout, but does not update the variable. Move the set variable step to be the very first line of your script so that a value is set in it every time the script runs.
Yeah but now if I delete all the records in both tables and put in two students and no payments, the students show up in my layout, but not in another layout I created (just a table view) just to see what the data looked like. In the new view of just the student there are two blank records in that view but in my main student view(the pretty one) they show...
Getting really frustrated now by what should be simple.
Any chance you can link to my file and try for your self to see?
"in another layout" What layout? (What did you name it so I can find it...)
"they show..." Show what?
If you've deleted all records from all tables, you should not see any records on any layout. If you see records, you either did not delete all the records (perhaps just those in the found set instead of all) or your layout is referring to a different table from those where you deleted all the records.
Layout is called StudentInfoLine
I deleted all records.
Added two students. No payments.
Students show in my "Students" layout.
Flip over to "StudentInfoLine" layout and nothing but two blank records.
Did you upload that file? I tried downloading from your last link, but can't find any such layout. I can find a StudentpaymentLine layout based on student payments but not a similar layout based on student info.
That one threw me for a moment.
I fixed this by:
enter layout mode
Select all objects (Ctrl A on windows)
In the formatting tool bar, select black as the text color.
Then return to browse mode.
In fileMaker it's very easy to end up with the last set of format options used as your "default" settings for any new objects you add to your layout.