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
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,831
Office Version
  1. 365
Platform
  1. Windows
Where are you setting the value fro currentrow?
 

Bogz17

New Member
Joined
Feb 19, 2019
Messages
11
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,831
Office Version
  1. 365
Platform
  1. Windows
Isn't that the code to populate the textboxes?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,530
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,109,351
Messages
5,528,192
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top