Auto populating multiple fields

Posted on 2011-10-04
Last Modified: 2012-05-12
I have a form called “Scheduling-Add”. When the user wants to add a new “Study” that is not in the system they click the “Studies” button on the form which opens another form called “Studies-Add” . When the user is filling the details on this form for the new studies, the record is automatically populated with a “studyAutoNbr” which is also the primary key in the upper right field of the form next to the “Close” button. This “studyAutoNbr” is automatically populated in the “Protocol Nbr” field. I also want this number populated in the “Study ID” field. Example if the new record about to be created has a new “AutoID” of 12355. This same ID “12355” is populated in the “Protocol Nbr” field and should be populated in the “Study ID” field. How can I accomplish this goal. Attached is a copy of my database with the form. Thanks in advance.
Question by:Chrisjack001
    LVL 2

    Expert Comment

    Hello Chrisjack001,

    I downloaded your database and had a look at the form_load event of the Studies-Add. Since the text box that represents Study ID is called Text39 (this is not a good convention, you could do better by changing the name of this text box to something like txtStudyID), you can add the following snippet after the first line of code in the form_load event:

    Me.Text39 = Me.txtProtocolNbr

    and it will resolve your problem.

    Hope that helps.


    Author Comment

    So will that number populated in the “studyAutoNbr” automatically populate in both the protocol and studyID fields?

    Author Comment

    where should I put this code. In what property event?
    LVL 2

    Accepted Solution

    yes it will autopopulate both the protocol and the studyID fields. Like I mentioned before, you should put that piece of code after the first line of the code in the form_load event of the Studies-Add form.

    This is what your form_load event should look like:

    Private Sub Form_Load()
        Me.txtProtocolNbr = Me.StudyAutoNbr
        Me.Text39 = Me.txtProtocolNbr
    End Sub

    Hope this helps.


    Author Closing Comment


    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now