By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

autopopulate fields from one form to another

100+
P: 111
i have a form that allows the user to enter the main information pertaining to a group. i have a button on this form that opens a second form that allows them to enter the individual people of this group and their info. They already entered the Group Name and Group Number on the first form, and i want it to carry over to the second form so that they dont have to retype it. The forms are based on two different tables. Is this possible? i tried using Dlookup, but its not working (or maybe im just not using it correctly). Any ideas?

Thanks!
Aug 9 '07 #1
Share this Question
Share on Google+
6 Replies


P: 37
After opening the other form with the docmd.openform you can set the value in it simply from the first form
forms("opened_form_name")("control_name")= forms("First_form_name")("Place_where_GroupID_is_s tored_name")

Some people will perfer the format me.Place_where_GroupID_is_stored_name but I think the first is more complete when your looking at a lot of code.
Aug 9 '07 #2

100+
P: 111
hmm that works, but not exactly what i need. It only stays in the first record thats opened on the new form, but as soon as they go to the next record it is gone.
Aug 9 '07 #3

P: 37
Then the easier way is to pass the form a value or a series of values through the Open arguments (OpenArgs). If you only have one value you could just pass that. Or if you have many sub values you could pass a primary key and get the rest as you go.
Aug 9 '07 #4

100+
P: 111
Sorry to be newbish, but im not familiar with the OpenArgs function - can you explain further?

Thanks!
Aug 10 '07 #5

P: 37
Sure. When you call a form with the docmd.open etc arguments at the end is an OpenArg statement. This is basically a string or a variant (I forget which) which you can pass information to the new form. The new form can reference it with the me.openargs statement. Since it is a pretty flexible thing you can pass the primary key for whatever data you have just requested to be passed. Then on any new record type command you can use that primary key to get the appropriate information out of your table. Sorry for the late reply I took a vacation.
Aug 13 '07 #6

100+
P: 111
That's okay - i was able to figure it out without using OpenArgs. I have a button that goes to the next record and just did what you recommened above for the previous form. Thanks though!
Aug 13 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.