title: Editing listbox item
body: <p>So i have a listbox that displays all the orders entered in the Order table using a select sql query. Now i also want to add the ability to edit the items from the listbox, i see the right click edit list item option but when i click it, it just opens the form but doesnt populate the fields. The form has textboxes that are unbound but i cant figure out how to get them to populate based on the right clicked entry. I have also tried to open the target form from vba and fill the fields through vba with the following code</p>
  <pre><code>Private Sub editrecordbttn_Click()
  Dim valSelect As Variant
  Dim v As Variant
  Dim selector As Variant
  Dim strValue As String ' just used for the demonstration
  Dim splitvalue() As String
  Dim selectedsampid As String
  Dim selectedcusid As String
  Dim Records As DAO.Recordset
  Dim SQLcus As String
  Dim SQLsamp As String
   
  For Each valSelect In Me.searchlistbox.ItemsSelected
      strValue = strValue &amp; &quot;&quot; &amp; Me.searchlistbox.ItemData(valSelect) &amp; &quot;,&quot; &amp; &quot;&quot; &amp; Me.searchlistbox.Column(1, valSelect) &amp; &quot;,&quot;
  Next valSelect
   
      ' to remove trailing comma
  strValue = Left(strValue, Len(strValue) - 1)
  
  splitvalue() = Split(strValue, &quot;,&quot;)
  selectedsampid = splitvalue(0)
  selectedcusid = splitvalue(1)
  
  DoCmd.OpenForm (&quot;Add Sample&quot;)
  Forms![Add Sample].fnametxt.SetFocus
  
  
  'query and fill cus info
  SQLcus = &quot;SELECT * FROM CustomerInfo WHERE CusID = '&quot; &amp; selectedcusid &amp; &quot;';&quot;
  Set Records = CurrentDb.OpenRecordset(SQLcus)
  Me!clienttypetxt = Records![Client type].Value
  
      
  </code></pre>
  <p>End Sub</p>