Hi All, I have a UserForm which I use a combo box to select a row of data. I want to be able to add/edit the data in that row from the UserForm. However, I keep getting a Run- time error '1004' when I run the cmdSubmitData code to update 2 cells.
Any assistance would be great. Cheers
Here is my code:
Any assistance would be great. Cheers
Here is my code:
Code:
Dim Currentrow As Long
Private Sub cmdSubmitData_click()
answer = MsgBox("Are you sure you want to update the records?", vbYesNo + vbQuestion, "update Record")
If answer = vbYes Then
Cells(Currentrow, 12) = txtNetWeight.Value
Cells(Currentrow, 13) = txtRate.Value
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmbClear_Click()
txtPatch.Text = ""
txtBins.Text = ""
txtPatch.Text = ""
End Sub
Private Sub cmbTruckDockets_DropButt*******()
Dim i As Long, LastRow As Long
LastRow = Sheets("Sheet1").range("B" & Rows.Count).End(xlUp).Row
If Me.cmbTruckDockets.ListCount = 0 Then
For i = 2 To LastRow
Me.cmbTruckDockets.AddItem Sheets("Sheet1").Cells(i, "B").Value
Next i
End If
End Sub
Private Sub cmbTruckDockets_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets("Sheet1").range("B" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Sheet1").Cells(i, "B").Value = (Me.cmbTruckDockets) Or _
Sheets("Sheet1").Cells(i, "B").Value = Val(Me.cmbTruckDockets) Then
Me.txtBins = Sheets("Sheet1").Cells(i, "G").Value
Me.txtPatch = Sheets("Sheet1").Cells(i, "c").Value
End If
Next
End Sub
Private Sub UserForm2_Initialize()
Currentrow = 5
txtPatch = Cells(Currentrow, 3)
txtBins = Cells(Currentrow, 7)
txtNetWeight = Cells(Currentrow, 12)
txtRate = Cells(Currentrow, 13)
End Sub
Last edited by a moderator: