ExtraCheese
New Member
- Joined
- Sep 18, 2020
- Messages
- 18
- Office Version
- 2016
- Platform
- Windows
I have created a database creation tool, where the user can add rows of data using an userform.
When the user wants to look up the entered data, he can click on another userform. This all works perfectly.
However, I would like to add the option for the user to also delete the data using the same userform as he used to find the data.
I have tried adding another button in the userform interface, but that didn't really work.
The user can enter the reference in 'Referentie', then click the 'Zoeken' button. Code below for this button.
When the user wants to look up the entered data, he can click on another userform. This all works perfectly.
However, I would like to add the option for the user to also delete the data using the same userform as he used to find the data.
I have tried adding another button in the userform interface, but that didn't really work.
The user can enter the reference in 'Referentie', then click the 'Zoeken' button. Code below for this button.
Private Sub CommandButton1_Click()
Dim id As String, rowcount As Long, foundcell As Range
Dim n As Long
id = TextBox3.Value
If id <> "" Then
With Worksheets("Data")
'ID is in col D
Set foundcell = .Columns("D").Find(What:=id, LookIn:=xlValues, lookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not foundcell Is Nothing Then
n = foundcell.Row
TextBox1.Value = .Cells(n, 1)
TextBox2.Value = .Cells(n, 2)
TextBox4.Value = .Cells(n, 3)
TextBox5.Value = .Cells(n, 7)
TextBox6.Value = .Cells(n, 8)
TextBox7.Value = .Cells(n, 5)
TextBox8.Value = .Cells(n, 6)
CommandButton1.Enabled = False
Else
TextBox1.Value = ""
TextBox2.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
MsgBox "Partijnummer niet gevonden"
End If
End With
End If