Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014

    Unanswered: Primary Key from one Form Autofills Foreign Key in another (NOT Sub form)

    I have a Patient data entry form (PK NHS Number) and an Admissions data entry form (FK NHS Number)

    Admissions is NOT a subform of Patient due to its size (it uses tab control and has 3 pages)

    When Admissions opens I would like NHS Number from the Patient Form to Autofill NHS Number in Admissions and the focus to go straight to the next field (Patient ID - this is hospital reference)

    I have looked at various similar threads but they don't seem to be quite what I need

    (either that or I just don't have the VBA skills needed!!!)


  2. #2
    Join Date
    Apr 2014
    Provided Answers: 34
    No vba should be needed.
    Select a patient from a list in a search form, like frmPatient

    Then use that pick to open the Admiss form using that patient chosen...
    docmd.openform "frmAdmissions", , , "[patientID]=" & Forms!frmPatient!txtPatID

  3. #3
    Join Date
    Sep 2014
    Thanks ranman but I don't have (or want) a search form - just want users to enter data with this form so have made it Data Entry = Yes

    When a new patient is added using the Patient data entry form a faux Save Button opens up the New Admissions data entry form so the new patient can be admitted

    Could your suggested code be added to the On Load or On Open events of the Admissions form?

    I have tried a very similar piece of code before but got an error message (was a day or two ago so cant remember exact wording)

    The end part txtPatID looks new - what does that do?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts