Note that there are some explanatory texts on larger screens.

plurals
  1. POAfter creating a new record, I can't get my form to display it in Access 2010
    text
    copied!<p>StackOverflow. I have an issue I've been grappling with for too long. Currently, I have a form that displays consortium data, with a button that says "Create new consortium." When I click it, it shows a pop up window that allows you to enter the name, as displayed in the image below. Almost everything works fine, except I can't get it to display the new record after I create it. See my code below--you'll get a sense of what I'm trying to do.</p> <p>By the way, if it matters, the "Consortium name" combo box allows you to select records. I don't see how it could throw my update off, but I thought I should include that information. </p> <p>Here's the form:</p> <p><img src="https://i.stack.imgur.com/o1F4V.png" alt="My form"></p> <p>Here's the code:</p> <p><img src="https://i.stack.imgur.com/Y5K8Y.png" alt="My code"></p> <p>Interestingly, StackOverflow doesn't seem to indent the code properly after making an edit--I was able to do it successfully with a new test post. Oh well. I'm a noob to this as well:</p> <pre><code>Private Sub CreateConsortiumButton_Click() If IsNull(Me.ConsortiumNameText) Or Me.ConsortiumNameText = "" Then ''insert better validation here MsgBox "Please enter a valid consortium name." Else '' Create a new Consortium record with the ConsortiumNameText field on the popup window Dim rst As DAO.Recordset Set rst = CurrentDb.OpenRecordset("Consortium") rst.AddNew rst("Consortium name").Value = Me.ConsortiumNameText ConsortiumID = rst("ConsortiumID").Value rst.Update '' Now, create a corresponding record in the ResearchContributions table Set rst = CurrentDb.OpenRecordset("ResearchContributions") rst.AddNew rst("ConsortiumID").Value = ConsortiumID rst.Update MsgBox "Consortium " &amp; Me.ConsortiumNameText &amp; " successfully created." '' Change the form's combo box to reflect the new record Forms!Main!NavigationSubform!ConsortiumNameCombobox = Me.ConsortiumNameText '' Close popup DoCmd.Close '' Attempt to set the record on the main form to the newly created one - NOT WORKING! DoCmd.OpenForm "Main", acNormal, , "[ConsortiumID] = " &amp; ConsortiumID End If End Sub </code></pre> <p>I think part of the issue may have to do with the fact that I've placed the "Consortium Form" form, which is based around a tab control, into the "Main" form. Perhaps because I'm trying to open the <em>Main</em> form with a certain ConsortiumID, that ConsortiumID doesn't apply to <em>Consortium Form</em>. It appears as though I can't link the master with its child, but this hasn't been necessary in the past. Please forgive me if the concepts sound vague in confused, for it is only because the concepts are vague and confused as of yet in my mind--this is my first Access project. Anyone have any tips?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload