Get Comment Text From Cell to Show in The Form

mehranmahouti

New Member
Joined
Oct 2, 2021
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I have a form like this image and in its database, some Cell has Comment in them.
What I want is, when I select a user from the form, the comment of each cell appears in a specific textbox (because there is more than one cell in a row that can have a comment), so each cell's comment should appear in its specified textbox (if there are any comments).
Also if I add or change any text in that textbox the text should appear as a comment on that cell.

How can I do that with the codes in this form?

form.png



These are the codes from Edit buttons Click event:


VBA Code:
Private Sub cmdEdit_Click()
    
    If Selected_List = 0 Then
        MsgBox "Herhangi bir satır seçilmedi.", vbOKOnly + vbInformation, "Edit" 
        Exit Sub
    End If
    
    'Code to update the value to respective controls
    
    Dim sGender As String
    Dim pBacak As String
    
    Me.txtRowNumber.Value = Application.WorksheetFunction.Match(Me.lstDatabase.List(Me.lstDatabase.ListIndex, 0), _
    ThisWorkbook.Sheets("Database").Range("A:A"), 0)
    
    Me.txtID.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 1)
    Me.txtName.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 2)
    sGender = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 3)
        If sGender = "KADIN" Then
            Me.optFemale.Value = True
        Else
            Me.optMale.Value = True
        End If

    Me.txtPaketSayisi.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 5)
    Me.txtAdres.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 6)
    Me.txtTel.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 7)
    Me.txtTC.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 8)
    Me.txtYas.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 9)
    Me.txtMeslek.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 10)
    Me.txtFiyat.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 11)
    Me.txtBorc.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 12)
    Me.txtToplamSeans.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 13)
    Me.txtBacakSafa.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 14)
    Me.txtGenitalSafa.Value = Me.lstDatabase.List(Me.lstDatabase.ListIndex, 16)
   ...
   ..
   .
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Here you can see the last preview of the form and what I want to do on it.

txtBacakSafa is the name of the textbox I get the value from cells in Column "O" (in this example O4).
txtBacakNot is the name of the textbox which I want to get the comment value from the same cell.
The sheet name in which all the data is located is "Database".


form2.jpg



When clicking on the save button it runs the below code:
So I need to edit here to be able to save new comments too.

VBA Code:
Function ValidateEntries() As Boolean

    ValidateEntries = True
    Dim iEmployeeID As Variant
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets("Print")
    iEmployeeID = frmForm.txtID.Value
    
With frmForm
        'Default Color
        .txtID.BackColor = vbWhite
        .txtName.BackColor = vbWhite
        .txtTel.BackColor = vbWhite
        .txtBacakSafa.BackColor = vbWhite
        .txtBacakIsil.BackColor = vbWhite
        .txtMeslek.BackColor = vbWhite
        .txtYas.BackColor = vbWhite
       ...
       ..
       . ([U]here are the same codes so I removed them[/U])
        '--------------------------------
    
        'Validating Duplicate Entries
        If Not sh.Range("B:B").Find(iEmployeeID, lookat:=xlWhole) Is Nothing Then
            MsgBox "Tekrarlanmış Dosya No Bulundu", vbOKOnly + vbInformation, "Emp ID"
            ValidateEntries = False
            .txtID.BackColor = vbRed
            .txtID.SetFocus
            Exit Function
        End If
    End With
End Function
 
Upvote 0

Forum statistics

Threads
1,214,670
Messages
6,120,831
Members
448,990
Latest member
rohitsomani

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