The only thing that I can see going wrong is that it is entering the wrong specimen number, causing them to not relate. But after the script enters the wrong specimen number, none of the other fields are being filled out afterwards.
What relationship have you defined linking Veterinary to Veterinary_Testing?
I would guess that you have something like:
Veterinary::Vet_Info_pKey = Veterinary_Testing::SomeFieldGoesHere
But your script never links the new record in Veterinary_Testing by assigning the value of Vet_info_pkey to a field in the new record. Since no such value is assigned, the new record does not appear to be linked to any record in Veterinary and thus all the set field steps will fail to assign data to the fields in the new record as the new record is not linked to any record from which the set field steps can copy the data.
You do copy the value of Vet_Info_pKey in to a variable: $$Vet_SpecNumber, but then your script does nothing more with this variable. Perhaps you have an auto-enter calculation set to use copy the value of this global variable into the match field in Veterinary_Testing, but this is not something that I can tell just from a look at your script. If you do have such an auto-enter calculation, check it very carefully to be sure that the name used in the calculation is spelled exactly the same as the name of the global variable used in your script.
I attached below the relationship I used between Veterinary and Veterinary Testing. The relationship is between Vet_info_pKey = Vet_Testing_fkey. I also attached below the auto-enter calculation I have used for the Vet_Testing_fkey to equal the global variable ($$Vet_SpecNumber).
The relationship and script work when there are no records relating to the fkey. However, once their is a record for a specific fkey, it enters the wrong specimen number in the specimen field and does not fill out any other fields, and also does not add this test information to the portal I have set up.
The vet_testing_fkey field should not both enter a serial number and also the value of the global variable. Thus, the first thing to do is to remove the auto-entered serial number setting and test to see if that makes a difference in the results that you get.
Vet_info_pkey is the field that should be set up as an auto-entered serial number, not the foriegn key field in Vetenary_Testing.
I removed the auto enter serial as you suggested and also deselected the unique value field for the f key. The script works perfectly now. Thanks Phil. I was banging my head on the desk over this one.