title: Setting the value of an Access combobox with VBA comparison
body: <p>I'm trying to figure out where I went wrong with this.</p>
  
  <p>I have two tables <code>Request</code> and <code>Parent</code>. <code>Request</code> can only have one related <code>Parent</code> record, but <code>Parent</code> can have many related <code>Request</code> records. So I have the <code>Request</code> table containing the foreign key to <code>Parent</code>.</p>
  
  <p>I have an unbound combobox that pulls it's data from the <code>Parent</code> table using a query (contains company name and ID bound to column 0 and 1, with column 1 being hidden so the user doesn't see the numeric ID). It's unbound because the form's recordset has a lot of complex joins, making anything on that form unable to be updated. So I created an "On Change" event on the combo box to fill in the foreign key using a querydef SQL update query:</p>
  
  <pre><code>Private Sub Combo217_Change()
  Dim ComboID As String
  Dim ReqID As Long
  Dim dbs As DAO.Database
  Dim qdfUpdateParentExisting As DAO.QueryDef
  
  ReqID = Me.RequestID.Value
  ComboID = Me.Combo217.Column(1)
  
  Set dbs = CurrentDb
  Set qdfUpdateParentExisting = dbs.QueryDefs("UpdateReqExistingParent")
  qdfUpdateParentExisting.Parameters("VBParent").Value = ComboID
  qdfUpdateParentExisting.Parameters("VBReqID").Value = ReqID
  qdfUpdateParentExisting.Execute
  qdfUpdateParentExisting.Close
  DoCmd.Save acForm, "DT2"
  Me.Requery
  
  End Sub
  </code></pre>
  
  <p>This works just fine, but once you exit the form and re-enter it, the value in the combo box is blank and I would like this to contain the same value that was selected.</p>
  
  <p>I've been trying to do an "On load event" with the following code but it's not working</p>
  
  <pre><code>Dim ParID
  ParID = Me.ParentID.Value
  Me.Combo217.Column(1).Value = ParID
  </code></pre>
  
  <p>Any input on getting this to work would be fantastic!</p>