Share via

Edit table through User Form update.

Dorian Grey 1 Reputation point
2022-09-27T05:50:01.487+00:00

Hello I spent more time on the macro to update the list box. It does make changes to the one I selected; however it just adds a new line with the changes leaving the original untouched. The words in bold are two lines I added. Many thanks to those who have helped me thus far.

Thank you,

Private Sub cmdEdit2_Click()   
  
If Selected_list2 = 0 Then   
  
Dim tbl As ListObject   
  
       Set tbl = Worksheets("Pallets").ListObjects("Table1")   
  
MsgBox "No row is selected.", vbOKOnly + vbInformation, "Edit"   
  
   
  
Exit Sub   
  
   
  
End If   
  
   
  
'code to update the value of respective controls   
  
Me.txtRowNumber2.Value = Selected_list2 + 1   
  
   
  
Me.txtDate.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0)   
  
Me.txtDestination.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 1)   
  
Me.txtPalletID.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 2)   
  
Me.txtTcns.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 3)   
  
Me.txtPieces.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 4)   
  
Me.txtWeight.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 5)   
  
Me.cmbShipment.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 6)   
  
Me.cmbSupport.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 8)   
  
Me.txtRemarks.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 9)   
  
   
  
MsgBox "Please make the required changes and click on 'Save' button to update,", vbOKOnly + vbInformation, "Edit"   
  
   
  
   
  
End Sub   
Developer technologies | Visual Basic for Applications
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.