Did you set up the relation in both directions? For your procedure, you would have to have set up the relation in the Patients database to link to the Admissions database. Perhaps you only set it up for the Admissions database to the Patients database. You probably want to do both.
When I run the procedure (selectrecordsrelatedto "admissions") from the ‘patients’ database, it selects all the records in ‘patients’ that have child records in ‘admission’.
What I would like (if possible), is to run a procedure from ‘patients’, which will find the record in ‘patients’ whose child I have previously highlighed/clicked in ‘admissions’:
I click on a record in ‘admissions’
I then switch to ‘patients’
I run a procedure in ‘patients’, which will find the record in ‘patients’ that corresponds to the record I had chosen in ‘admission’ (in step 1)
I don’t think I read your question carefully enough. The fieldvalue( function would be your first step. You would use it to retrieve the key value from the record in the admissions database, and then you would use a Find statement to find the desired record in patients.
The statement that you want is SelectRelated, not SelectRecordsRelatedTo.
It is expected that you would be using SelectRelated from the database that has the criteria. This statement looks at the data in the current record, and then automatically changes to a different database and selects the records that are linked to that record.
In your case, it is expected that you would be in the Admissions db, and use the statement to have the procedure first move to the Patients file, and then select those records that matched the active record in the Admissions file when the statement was initiated.
There are ways to do this with the extra steps that you stated, but I’m guessing that just initiating this from the Admissions db will be fine. And the Statement would be
SelectRelated “Patients”
Again, this statement says “I like the PatientID in this current record in my Admissions file. Change to the Patients db and select the Patient that has this PatientID.”
@Rameeti Thank you! What I was somewhat different. While in the ‘patients’ database, I wanted to know which which patient record matches the record I had already clicked in the ‘admissions’ file.
//This script finds the record in the ‘Patients’ database that matches the patientID that corresponds to the record clicked in the ‘admissions’ database