Eternallamp
New Member
- Joined
- Feb 16, 2024
- Messages
- 9
- Office Version
- 2007
- Platform
- Windows
In my Excel user form, the option to click on a row in the list box and return the selected entry into my data entry fields. After making changes and attempting to save, no updates are made. If i comment out the click event to select a row from the list box, then the Save command works fine. Note, my data starts in the fourth row of the worksheet. So it seems, the save event is triggering the selected event and my updates disappear. Do appreciate your insights into this.
Code to select and return selected into form for editing:
Private Sub lstLoanRates_Click()
Dim SelectedRec As Integer
For i = 0 To lstLoanRates.ListCount - 1
If lstLoanRates.Selected(i) = True Then
txtRefNo.Value = Worksheets("LoanRates").Cells(i + 4, 1).Value
txtLoanNo.Value = Worksheets("LoanRates").Cells(i + 4, 4).Value
txtProgId.Value = Worksheets("LoanRates").Cells(i + 4, 6).Value
txtIntRate.Value = Worksheets("LoanRates").Cells(i + 4, 8).Value
txtDisbDate.Value = Worksheets("LoanRates").Cells(i + 4, 9).Value
End If
Next i
End Sub
Code to save.
Private Sub cmdSave_Click()
i = txtRefNo.Value + 3
Worksheets("LoanRates").Cells(i, 1).Value = txtRefNo.Value 'Then
Worksheets("LoanRates").Cells(i, 8).Value = Me.txtIntRate.Value
Worksheets("LoanRates").Cells(i, 9).Value = Me.txtDisbDate.Value
Worksheets("LoanRates").Cells(i, 14).Value = Me.txtComments.Value Sub
End Sub
Code to select and return selected into form for editing:
Private Sub lstLoanRates_Click()
Dim SelectedRec As Integer
For i = 0 To lstLoanRates.ListCount - 1
If lstLoanRates.Selected(i) = True Then
txtRefNo.Value = Worksheets("LoanRates").Cells(i + 4, 1).Value
txtLoanNo.Value = Worksheets("LoanRates").Cells(i + 4, 4).Value
txtProgId.Value = Worksheets("LoanRates").Cells(i + 4, 6).Value
txtIntRate.Value = Worksheets("LoanRates").Cells(i + 4, 8).Value
txtDisbDate.Value = Worksheets("LoanRates").Cells(i + 4, 9).Value
End If
Next i
End Sub
Code to save.
Private Sub cmdSave_Click()
i = txtRefNo.Value + 3
Worksheets("LoanRates").Cells(i, 1).Value = txtRefNo.Value 'Then
Worksheets("LoanRates").Cells(i, 8).Value = Me.txtIntRate.Value
Worksheets("LoanRates").Cells(i, 9).Value = Me.txtDisbDate.Value
Worksheets("LoanRates").Cells(i, 14).Value = Me.txtComments.Value Sub
End Sub