Oops it seems the automatic smiley thing messed up my script above. Just pretend any :P is supposed to be a "colon" with a "P". Sorry about that!
Insert Calculated Result [Select; Patients::Patient ID = $id]
Could someone please tell me what I'm doing wrong?
If you are correct in the exact wording of the Insert Calculated Result line then ...that is your error.
Your calculation asks (in simple-talk): Does PatientID = $ID? This is a boolean result of 1 or 0.
Your script step, when viewing it, should look like:
Insert Calculated Result [Select; Patients::Patient ID ; $id ] ... note there is NO equal sign? You have not entered your PatientID into the target field Specify portion. YOu instead entered it all into the calculation. Your calculation should ONLY have $id in it. :smileyhappy:
As for your script, how about (untested and always back up first):
Show All Records
Show Omitted Only
Exit Loop If [ not Get ( FoundCount )
Go To Record/Request/Page [ Last ]
You will have one record in your found set - the one you create. The reason for the loop is to protect from multi-user mode, ie, if the moment before you 'show omitted only' another User adds a record, it will pop into your record set. So the loop says, if that happens, omit that record until it is sure you have zero records in your found set. Then create your new record.
Searching for the new ID works as well but I wouldn't use Insert Calculated Result - it is best to use Set Field.
Oh okay I understand the first post. And after trying it, I tossed out my script and used yours and it works PERFECTLY! Thank you again, LaRetta :)