Results 1 to 10 of 10
  1. #1
    GarrynGirl is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2020
    Posts
    5

    Linking 2 forms with Command Button

    Hi
    Newbie here so please be gentle.
    I apologise if this has been previously asked. I did try searching but in a world of confusion.

    My question is this:


    I have a main form - Patient Data - which I want to link a 2nd form to - Medications. I want the Patient MRN (patient unique ID), the Patient first name, Patient surname and date of birth to automatically come across from the Patient Data to the Medications form.

    I have tried to set up using a Command Button linking the unique field MRN but when I click on the Command Button (which is placed in the Patient Data form) to open the Medications form no data appears.

    I have tried using youtube videos and have followed exactly but still no data appears. What can I do so that the same data appears in both forms?

    Thanks for any help. I know this is probably a very simple fix but not so easy when it doesn't work!

    Using Access 2013 on Windows 10.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,007
    I would use the OpenArgs argument on the open method of the form and parse that data out when it is received in the Medications form.
    You could also just pass the ID and look for the data again, by setting the recordsource?
    You could also have a subform for the medications, automatically linked by your ID.

    Lots of different ways TBH, depending on how you choose to do it.?

    Also make sure that the Medications form does not have Date Entry set to Yes (as that is append mode only).
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    GarrynGirl is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2020
    Posts
    5
    Thank you, I will try those alternative methods but shouldn't it just display the data by using the command button as it is intended to link the forms?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Quote Originally Posted by GarrynGirl View Post
    I have a main form - Patient Data - which I want to link a 2nd form to - Medications. I want the Patient MRN (patient unique ID), the Patient first name, Patient surname and date of birth to automatically come across from the Patient Data to the Medications form.
    Can you confirm that you have a field called "Patient MRN" in both the Patient Data table and also in the Medications table.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    GarrynGirl is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2020
    Posts
    5
    Bob, yes the Patient MRN is in both tables, as a unique key field.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,007
    As a separate form?, No.

    You can also open the form with the Where argument, but essentially YOU have to tell the form what record you want, unless it is linked in it's properties.?
    Thinking about it further, the Where argument would be a better solution?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    GarrynGirl is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2020
    Posts
    5
    I thought the Command Button would link the data using MRN<>MRN?

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,007
    Quote Originally Posted by GarrynGirl View Post
    I thought the Command Button would link the data using MRN<>MRN?
    Not even sure the wizard will do that.?

    However computers are stupid and will only do what you instruct them to do. Get it wrong, and they will not say 'oh I know you meant this', they will just ignore you, or give you an error message.

    Review the Northwind example that comes with Access.

    Also you need Form2.MRN = Form1.MRN ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    GarrynGirl is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2020
    Posts
    5
    Haha stupid computers. Yes I had my Form2.MRN=Form1.MRN around the wrong way. Thanks for all your help.

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    Looks like you solved it but just to make sure I hope you do not have the other fields you mention in your original post (patient first name, surname and DOB) in both tables as that would go against the rules of good database design (normalization).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Please reply to this thread with any new information or opinions.

Similar Threads

  1. same command button on different forms
    By Khalil Handal in forum Modules
    Replies: 12
    Last Post: 03-07-2022, 03:03 AM
  2. Replies: 4
    Last Post: 09-05-2016, 10:27 AM
  3. Replies: 12
    Last Post: 10-20-2014, 11:22 AM
  4. Add Command Button to Multiple Forms
    By jameslefebv in forum Forms
    Replies: 4
    Last Post: 07-14-2014, 07:07 PM
  5. Access 2010 Forms Command button Question
    By RayMilhon in forum Forms
    Replies: 3
    Last Post: 09-12-2011, 03:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums