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

Using a Textbox in Form1 to Populate and Store Info in a Textbox in Form2

P: 7
I am very new to Access and am setting up a database that will house data from biological studies. I have two forms and associated tables set up, the first called "TrapNights" in which information on environmental data during the time of a trap night survey is entered, and a second called "IndividualData" that collects information about specific animals seen during that particular trap night. These two forms/tables are related based on the field "TrapNightID". TrapNightID is the primary key in the TrapNights table, and the foreign key in the IndividualData table.
I want to have the TrapNights form open, have the user enter that data, then click a button that opens up the IndividualData table. The problem I'm having is that I have a textbox field for the TrapNight foreign key in the IndividualData form. I want this to be auto-populated based on the Primary key that was generated for the record that was just entered in the TrapNight form.
At this point, I have the field auto-populating the number, but it is simply displaying the number and is not bound to the field in the table and storing the number in the IndividualData table.
Does anyone know how I can reconcile this and get the data to be stored in the IndividualData table rather than just displaying the number?
Any help would be greatly appreciated, please let me know if any further explanation is necessary. Thank you in advance for any help.
Jul 2 '14 #1

✓ answered by twinnyfo

Is your individual data form a subform on the main form trapnight? It may be wise to do that and that may solve the majority of your problems.

Share this Question
Share on Google+
7 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,482
aeroach,

You say that the TrapNightID is the primary key of table TrapNights and in the Foreign Key in table Individual Data. I don't understand the problem.....

Your table should be displaying the ID number of TrapNightID--which is exactly what it is doing.

Perhaps I don't understand your question??
Jul 2 '14 #2

P: 7
Sorry, let me try to clarify. In my TrapNights form, the TrapNightID textbox is displaying the automatically generated auto-number for that field for each record entered.
In the IndividualData form that opens subsequently, that auto-number is being displayed in the TrapNight textbox field for the IndividualData table, but there is some disconnect, and that number is only displaying in the field and not actually getting sent to and stored in the IndividualData table.
Jul 2 '14 #3

twinnyfo
Expert Mod 2.5K+
P: 3,482
If your Form/Sub-form is set up with the Master-Child relationship set to TrapNightID, the TrapNightID should be updated automatically with every new record for that TrapNightID. Nor should there be a need to display either the TrapNightID or the IndividualDataID fields on the form.
Jul 2 '14 #4

P: 7
Yes, I see your point, that is something I intend to remove once I have the database running exactly as intended. I don't want to have the auto-number ID fields displayed on the forms, but for now it's just been a way for me to verify that information is getting transferred to the right places in the way I want it to be. And unfortunately it's not... TrapNightID is updated in the TrapNight form/table as desired... but not in the IndividualData form/table.
I'm not sure if this will help, but here are images of my two forms and the fields I'm dealing with:

TrapNight: http://i.imgur.com/fYNZRfy.jpg
IndividualData: http://i.imgur.com/o0wijfX.jpg

When I open the TrapNight form and enter TrapNightID record 1... then open up IndividualData form, TrapNight in that form is automatically populated to a value of '1'. But it's only showing me that and not putting it into the table.
Jul 2 '14 #5

twinnyfo
Expert Mod 2.5K+
P: 3,482
Is your individual data form a subform on the main form trapnight? It may be wise to do that and that may solve the majority of your problems.
Jul 2 '14 #6

P: 7
I had it as two distinct forms... I put the IndividualData form in as a sub-form on TrapNight and that's resolved the issue. Thank you very much for your help!
Jul 2 '14 #7

twinnyfo
Expert Mod 2.5K+
P: 3,482
Glad that I could help! Let us know if you run across any other snags!
Jul 2 '14 #8

Post your reply

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