[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Auto populating multiple fields

Posted on 2011-10-04
Medium Priority
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
  • 3
  • 2

Expert Comment

ID: 36913514
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

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

Author Comment

ID: 36913596
where should I put this code. In what property event?

Accepted Solution

ref-IT earned 2000 total points
ID: 36913690
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

ID: 36917183

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

872 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