Vb update records

Bogz17

New Member
Joined
Feb 19, 2019
Messages
11
HI guys

i have getting a problem about my userform for updating records . i have 16 TEXTBOX in my USERFORM and to get the the data i use search button in my userform.
well the problem is when after i search the data and update it when i click the update button the data that i updated was appear in the first row and replace the data that was in there .
wish someone can help me her.:(

here are my code for update button




answer = MsgBox("Are you sure you want to update the record?", vbYesNo + vbQuestion, "Update Record")








If answer = vbYes Then
Cells(currentrow, 1) = TextBox1.Text
Cells(currentrow, 2) = TextBox2.Text
Cells(currentrow, 3) = TextBox3.Text
Cells(currentrow, 4) = TextBox4.Text
Cells(currentrow, 5) = TextBox5.Text
Cells(currentrow, 6) = TextBox6.Text
Cells(currentrow, 7) = TextBox7.Text
Cells(currentrow, 8) = TextBox8.Text
Cells(currentrow, 9) = TextBox9.Text
Cells(currentrow, 10) = TextBox10.Text
Cells(currentrow, 11) = TextBox11.Text
Cells(currentrow, 12) = TextBox12.Text
Cells(currentrow, 13) = TextBox13.Text
Cells(currentrow, 14) = TextBox14.Text
Cells(currentrow, 15) = TextBox15.Text
Cells(currentrow, 16) = TextBox16.Text
End If






listDisplay1.ColumnCount = 16
listDisplay1.RowSource = "A1:J65356"
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Where are you setting the value fro currentrow?
 
Upvote 0
currentrow = 2
TextBox1 = Cells(currentrow, 1)
TextBox2 = Cells(currentrow, 2)
TextBox3 = Cells(currentrow, 3)
TextBox4 = Cells(currentrow, 4)
TextBox5 = Cells(currentrow, 5)
TextBox6 = Cells(currentrow, 6)
TextBox7 = Cells(currentrow, 7)
TextBox8 = Cells(currentrow, 8)
TextBox9 = Cells(currentrow, 9)
TextBox10 = Cells(currentrow, 10)
TextBox11 = Cells(currentrow, 11)
TextBox12 = Cells(currentrow, 12)
TextBox13 = Cells(currentrow, 13)
TextBox14 = Cells(currentrow, 14)
TextBox15 = Cells(currentrow, 15)
TextBox16 = Cells(currentrow, 16)

thats my code for currentrow
 
Upvote 0
Isn't that the code to populate the textboxes?
 
Upvote 0
How about
Code:
If answer = vbYes Then
   NxtRw = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
   Cells(NxtRw, 1) = TextBox1.Text
   Cells(NxtRw, 2) = TextBox2.Text
   Cells(NxtRw, 3) = TextBox3.Text
   Cells(NxtRw, 4) = TextBox4.Text
   Cells(NxtRw, 5) = TextBox5.Text
   Cells(NxtRw, 6) = TextBox6.Text
   Cells(NxtRw, 7) = TextBox7.Text
   Cells(NxtRw, 8) = TextBox8.Text
   Cells(NxtRw, 9) = TextBox9.Text
   Cells(NxtRw, 10) = TextBox10.Text
   Cells(NxtRw, 11) = TextBox11.Text
   Cells(NxtRw, 12) = TextBox12.Text
   Cells(NxtRw, 13) = TextBox13.Text
   Cells(NxtRw, 14) = TextBox14.Text
   Cells(NxtRw, 15) = TextBox15.Text
   Cells(NxtRw, 16) = TextBox16.Text
End If
 
Upvote 0

Forum statistics

Threads
1,224,395
Messages
6,178,348
Members
452,841
Latest member
GenAkaman

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