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

Pass field from one form to the next

P: 31
I have a mainform (form1, with its own table), which has an autonumber field named ID. On form1, i have a button to open form2, that i need the ID number on, but it has its own ID field(not just reusing the same field). I have defined the relationships for the tables with the ID number, but i am not sure how to make the ID from table 1 to automatically load in table 2. I assume that it will use code on the onload of table 2, but i am kinda lost on the code. I tried this with onLoad but i am sure that you can tell why it doesn't work (although I cant :)

me![id] = id_table1

I understand that this doesnt actually tell it from where to get the id_table1

the button on form1 has this

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "mat_cert_form"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Since all of my forms (quite a few, each with different tables) will progressivly use the same number but saved for each table, this will help me out on alot of forms. Sometimes i know what i mean to say, but i dont quite communicate it very well. If you need to understand more about my problem, just ask. I am not very good with this, but i am getting smarter everyday (thanks to a bunch of you)
Aug 19 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 184
What you need to do here is create a relationship for the ID in table to to the ID in table 1.

Do not assign the ID in table 2 as an autonumber field. Instead assign it as number with Long Integer as the formatting then create a lookup on that Field in table 2 to get the values from ID in table 1.

What I have been doing so far is to use the Lookup wizard in the Design view of the table. There are some articles not suggesting this but it has not failed me ever since.

You go to design view of your table 2 and change the ID field to a Foreign Key. If it is currently in Autonumber, change it to number and format as Long Integer. Save it and afterwards select Lookup Wizard from the dropdown and the Lookup wizard will guide you in creating that relationship.
If there is an existing relationship between the two, you may have to delete that first. Then select table 1 and the field ID from the Wizard.
Save it and go back to Datasheet view of your table two. The ID Field should now be a combobox looking up values from table1.

of course, if there are no entried in table 1 yet, you would not see anything in the dropdown box.
Aug 19 '08 #2

Post your reply

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