2 Replies Latest reply on Sep 18, 2012 8:14 PM by zubir007

    Linking two tables together

    zubir007

      Hi,

       

      I have this database that I've been working on (attached below). Currently when I click on new patientit creates a new record and allows me to fill out the form. I also have a next button on the form for new patient layout that takes me to the layout with the tabs, however, I am not how to link the two layouts together so that it is actually counts for one record for the patient. How do I do this can someone please provide me with step by step instructions on how to do this. Thank you.

        • 1. Re: Linking two tables together
          MattLeach

          You need to setup a relationship between the two tables.

           

          The first thing i would do would be to add a primary key to each table. The table in which you are linking to would need a foregin key. So using your tables as an example, i would add:

           

          New_Patient_Layout::_pk_PatientID

           

          crf_table::_pk_ReportID

          crf_table::_fk_PatientID

           

          I would then link the tables as follows:

           

          New_Patient_Layout::_pk_PatientID = crf_table::_fk_PatientID

           

          You would need to create a script and attach it to the next button that would do the following:

           

          take the patient ID from the New_Patient_Layout table and set is in a variable

          Go to the case reports form layout

          create a new record

          set the crf_table::_fk_PatientID field with the variable set above

           

          This will create a new record in the crf_table and set the foreign key as the patient ID so that it is now linked with the patient record.

          • 2. Re: Linking two tables together
            zubir007

            Hi

             

            I c what your saying but ive nevrr done this before can u give me like baby step instructions on how to do this like first click file etc etc. I would much appreciate it if u could thank u.