I am not sure why my code is not working. This part of my program is for updating a record. So the user would enter in the license plate number which is the criteria for the record search and then enter in their updates in the remaining text boxes. My problem is that I want my program to send a msgbox if the plate number they entered is not in the database (invalid). with the code I have below it sends a msgbox for a license plate that is not in the database (invalid) but also sends a msgbox for a license plate that is inside the database (valid), which I do not want to occur. How do I fix this?
Thank you in advanced.
Private Sub CommandButton1_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Vehicle Records").Range("I" & row_number)
If item_in_review = TextBox1.Text Then
Sheets("Vehicle Records").Range("O" & row_number) = TextBox2.Text
Sheets("Vehicle Records").Range("Q" & row_number) = TextBox3.Text
Sheets("Vehicle Records").Range("R" & row_number) = TextBox4.Text
Else
MsgBox "Plate Number Does Not Exist"
Exit Sub
End If
Loop Until item_in_review = ""
End Sub
Thank you in advanced.
Private Sub CommandButton1_Click()
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Vehicle Records").Range("I" & row_number)
If item_in_review = TextBox1.Text Then
Sheets("Vehicle Records").Range("O" & row_number) = TextBox2.Text
Sheets("Vehicle Records").Range("Q" & row_number) = TextBox3.Text
Sheets("Vehicle Records").Range("R" & row_number) = TextBox4.Text
Else
MsgBox "Plate Number Does Not Exist"
Exit Sub
End If
Loop Until item_in_review = ""
End Sub
Last edited: