Here's my UserForm:
Here's the fabulous code that (finally) makes it work and quite possibly saved my job:
Here's the code I have to delete the entire row of the currently displayed record from the DataCenter sheet:
It doesn't work. I'm thinking the problem is that despite the information displaying on the UserForm, it isn't selected on the database sheet. Am I close?
Here's the fabulous code that (finally) makes it work and quite possibly saved my job:
VBA Code:
Private Sub cmdSearchSubCode_Click()
Dim SubCode_id As String
SubCode = Trim(SubCode.Text)
lastrow = Worksheets("DataCenter").Cells(Rows.Count, 2).End(xlUp).Row
For i = 1 To lastrow
If Worksheets("DataCenter").Cells(i, 3).Value = SubCode Then
SubCode.Text = Worksheets("DataCenter").Cells(i, 2).Value
SubName.Text = Worksheets("DataCenter").Cells(i, 5).Value
SubInitials.Text = Worksheets("DataCenter").Cells(i, 4).Value
FieldManager.Text = Worksheets("DataCenter").Cells(i, 7).Value
End If
Next
End Sub
Here's the code I have to delete the entire row of the currently displayed record from the DataCenter sheet:
VBA Code:
Private Sub cmdDeleteSub_Click()
Answer = MsgBox("Are you sure you want to delete this Subdivision completely? There is no undo", vbyeYesNo + vbQuestion, "Delete Record?")
If Answer = vbYes Then
Cells(currentrow, 1).EntireRow.Delete
End If
End Sub
It doesn't work. I'm thinking the problem is that despite the information displaying on the UserForm, it isn't selected on the database sheet. Am I close?
Last edited: