Adding new record when trying to update thru 'update command button' in userform

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
------------------------

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:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top