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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aeroach
    New Member
    • Jul 2014
    • 7

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

    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 "TrapNightI D". 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.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3660

    #2
    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??

    Comment

    • aeroach
      New Member
      • Jul 2014
      • 7

      #3
      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.

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3660

        #4
        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 IndividualDataI D fields on the form.

        Comment

        • aeroach
          New Member
          • Jul 2014
          • 7

          #5
          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.

          Comment

          • twinnyfo
            Recognized Expert Moderator Specialist
            • Nov 2011
            • 3660

            #6
            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.

            Comment

            • aeroach
              New Member
              • Jul 2014
              • 7

              #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!

              Comment

              • twinnyfo
                Recognized Expert Moderator Specialist
                • Nov 2011
                • 3660

                #8
                Glad that I could help! Let us know if you run across any other snags!

                Comment

                Working...