Vivek Roshan
New Member
- Joined
- Feb 15, 2018
- Messages
- 24
Hello Everybody,
I have created a USERFORM which has command buttons namely CLEAR, ADD, SEARCH, UPDATE, DELETE, PRINT, CLOSE. All commands are functioning except UPDATE BUTTON. When I am searching a record through combo box, search result is perfect. But after making some changes in the record when I am updating the record through UPDATE COMMAND BUTTON, a new record is being added instead of update on the same record. Code is mentioned below. Any help to resolve this problem will be highly appreciated.
Thanks with regards,
Vivek
------------------------
I have created a USERFORM which has command buttons namely CLEAR, ADD, SEARCH, UPDATE, DELETE, PRINT, CLOSE. All commands are functioning except UPDATE BUTTON. When I am searching a record through combo box, search result is perfect. But after making some changes in the record when I am updating the record through UPDATE COMMAND BUTTON, a new record is being added instead of update on the same record. Code is mentioned below. Any help to resolve this problem will be highly appreciated.
Thanks with regards,
Vivek
------------------------
Code:
Private Sub Cmd_Update_Click()
Dim Fvalue As Range
Set Fvalue = Sheet2.Range("A:A").Find(What:=Me.ComboBox1.Value, LookIn:=xlFormulas, LookAt:=xlWhole)
If Not Fvalue Is Nothing Then
Fvalue.Value = Me.TextBox5.Value
Fvalue.Offset(0, 1).Value = Me.TextBox1.Value
Fvalue.Offset(0, 2).Value = Me.TextBox2.Value
Fvalue.Offset(0, 3).Value = Me.TextBox3.Value
Fvalue.Offset(0, 4).Value = Me.TextBox4.Value
Fvalue.Offset(0, 5).Value = Me.TextBox6.Value
Fvalue.Offset(0, 6).Value = Me.ListBox1.Value
Fvalue.Offset(0, 7).Value = Me.ListBox2.Value
If OptionButton1.Value Then
Fvalue.Offset(0, 8).Value = "YES"
Else
If OptionButton2.Value Then
Fvalue.Offset(0, 8).Value = "NO"
End If
End If
If OptionButton3.Value Then
Fvalue.Offset(0, 8).Value = "PENDING"
End If
End If
Fvalue.Offset(0, 9).Value = Me.TextBox7.Value
Fvalue.Offset(0, 10).Value = Me.TextBox8.Value
Cmd_Clear_Click
MsgBox "Update successfully...!", vbInformation, "Data Updated."
End Sub
Last edited by a moderator: