Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009

    Unanswered: Set value of a text box according to typed paramater

    Hello everyone,

    I am doing a project for a hospital. Well I want to press a button named "Enter patient" and by pressing this a form to enter patient's personal data is opened. Then user is pressing save. Then there is a button to enter the medicines that this patient takes. By pressing the button (i have created a form, connecting with a query) is asking you to put the ID of the patient that you want to write the medicines. Now on the opened form how can I do ID field of medicines table be the same as i typed in the parameter?
    E.g: I typed ID=4 and the form "Enter Medicines" in opened. Now the ID of the form "Enter Medicines" is empty. How can i do it take the number 4 or the number that I typed each time.
    Thanks in advance!

  2. #2
    Join Date
    Jan 2009
    Kerala, India

    Set value of a text box according to typed paramater

    You can do this with a Button_Click() Event Procedure on the Main Form and with a one line Code on the Form_Load() Event Procedure on the PatientMedicine Form.

    Write the following sample Code (with changes for inserting the correct Form control Name to pick the ID value) on the Command Button Click Event Procedure:

    Private Sub Command29_Click()
    DoCmd.OpenForm "PatientMedicine", acNormal, , , , , Me![PatientID]
    End Sub
    The PatientID Value is passed as Open Argument to the Form PatientMedicine that you can read and set in the PatientID field on the Form with the following Code:

    Private Sub Form_Load()
    Me![PatientID] = Me.OpenArgs
    End Sub (Learn MS-Access Tips & Tricks)
    Learn Advanced MS-Access Programming with sample VBA Code.

    All responses are based on Access 2003/2007

Posting Permissions

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