Display information in second form

JessyVal

New Member
Joined
Feb 23, 2021
Messages
30
Office Version
  1. 365
Hi, me again, Sorry for ask many question, I am new in vba excel.

I have a form, this form allows you to look for a person (probably I have many people named David), in case you have many registers with one name (but different last name) you can pick wich register you want to update.

1618934084685.png


once you select a person , a new form is displayed

1618934129415.png


what I want to do is, once you select the person in the first form, and click in Modify, i would like to be able to see the information of that particular person displayed in this second form, and will be able to edit it.

Now, the code that I have in the second form is

VBA Code:
Private Sub btnEdit_Click()

Dim vol_name As String
vol_name = Trim(txtbox.Text)

lastRow = Worksheets("Registers").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastRow


    If Worksheets("Registers").Cells(i, 2).Value = vol_id Or Worksheets("Registers").Cells(i, 3).Value = vol_name Then
    
    answer = MsgBox("Are you sure you want to update the record?", vbYesNo + Question, "Update Record")
    If answer = vbYes Then
    
    Worksheets("Registers").Cells(i, 3).Value = txtvolName.Text
    Worksheets("Registers").Cells(i, 4).Value = txtvolLastName.Text
    Worksheets("Registers").Cells(i, 5).Value = txtvolEmail.Text
    Worksheets("Registers").Cells(i, 6).Value = txtvolAddress.Text
    Worksheets("Registers").Cells(i, 7).Value = txtcity.Text
    Worksheets("Registers").Cells(i, 8).Value = txtcounty.Text
    Worksheets("Registers").Cells(i, 9).Value = txteircode.Text
    Worksheets("Registers").Cells(i, 10).Value = txtphone.Text
    Worksheets("Registers").Cells(i, 11).Value = txttwitter.Text
    Worksheets("Registers").Cells(i, 12).Value = schedule_list.Text
    Worksheets("Registers").Cells(i, 13).Value = txtgarda.Text
    Worksheets("Registers").Cells(i, 14).Value = help_list.Text
    Worksheets("Registers").Cells(i, 15).Value = txtzendesk.Text
    Worksheets("Registers").Cells(i, 16).Value = txtmicro_365.Text
    
    MsgBox "The record is updated"
    Exit Sub
    
    Else
    MsgBox "The record is not going to be updated"
    Exit Sub
    
    End If
    
    End If


 Next

Unload Me
End Sub


Private Sub UserForm_Initialize()
frmUpdateVolunteer.Show

For i = 1 To 3
    Me.Controls("Textbox" & i).Value = ActiveCell.Offset(0, i - 1).Value
Next i

End Sub


Thank you
 
Woaw!!
Thanks a lot, it is what I was trying to do.

Hi,
glad it does what you want

- for fun, I had a little play after my original post that does it all on the main userform - just type in search box & list of matches should appear. Double click required record to populate the form.


Dave
 
Upvote 0
Solution

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,
glad it does what you want

- for fun, I had a little play after my original post that does it all on the main userform - just type in search box & list of matches should appear. Double click required record to populate the form.


Dave
OMG, it is very cool!! I will study the code very carefuly in order to lear how you did it.
Thanks a million!!
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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