none
lijn = "<strong><u>" & text & "</u></strong>" stays underlined and bold RRS feed

  • Question

  • I have a memo field. users can slect in a listbox lines to add to the memofield.

    the cursor comes after the lijn - field . If the user then enters some text, the added text is underlined too , although I've put </u></strong> ... only if I give a line-break too , the underlining stops ...

    Tuesday, June 14, 2016 10:35 AM

Answers

  • Hi tekoko,

    Which code you used? I made a test with below code, I only get an empty space instead of line break.

    Private Sub Command24_Click()
    Me.MemoField.SetFocus
    Me.MemoField.Text = "<div><strong><u>test</u></strong> </div>"
    End Sub

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by tekoko10 Thursday, June 16, 2016 6:01 AM
    Thursday, June 16, 2016 5:22 AM

All replies

  • I'm still not clear what is happening vs. what you would like instead, nor have you explained how this is all being done.  VBA code?

    Please explain in detail and post your code for us to review it and offer suggestions.


    Daniel Pineault, 2010-2012 Microsoft MVP
    http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Tuesday, June 14, 2016 12:44 PM
  • Private Sub Knop1732_Click()
    '
    '
    '
       Dim varItem As Variant
        Dim IDList As String
        Dim ctl As Control
        Dim ctrl As Control
        Dim lijn As String
        Set ctrl = Me.lijstv

        If ctrl.ItemsSelected.Count > 0 Then
        Set ctl = Me.ficheverloop
            For Each varItem In ctrl.ItemsSelected
            lijn = ctrl.ItemData(varItem)
            If (Left(lijn, 6) = "TIMING") Then lijn = "<strong><u>" & lijn & "</u></strong>"
            If (Left(lijn, 9) = "PRAKTISCH") Then lijn = "<strong><u>" & lijn & "</u></strong>"

              Me!lijstv.Selected(varItem) = False

                Call InsertAtCursor(ctl, lijn)

            Next varItem

        Else
            MsgBox "geen lijnen gekozen"
        End If

        End Sub

                                                
    Tuesday, June 14, 2016 1:52 PM
  • What is the code for InsertAtCursor? Maybe it's not putting the cursor after the closing tags.

    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Tuesday, June 14, 2016 3:01 PM
  • Public Function InsertAtCursor(ByRef ControlName As Control, strChars As String, Optional strErrMsg)
     
        Dim strPrior As String      'Text before the cursor.
        Dim strAfter As String      'Text after the cursor.
        Dim lngLen As Long          'Number of characters
        Dim iSelStart As Integer    'Where cursor is.
        Dim strtekst As String
      On Error GoTo Err_Handler
      
        ControlName.SetFocus
        ControlName.SelStart = ControlName.SelLength
      
        If strChars <> vbNullString Then
            With Screen.ActiveControl
                If .Enabled And Not .Locked Then
                    lngLen = Len(.Text)
                    strPrior = .Text
                    'SelStart can't cope with more than 32k characters.
                    If lngLen <= 32767& - Len(strChars) Then
                        'Remember characters before cursor.
                        iSelStart = lngLen
                        .Value = strPrior & strChars
                        'Put the cursor back where it as, after the new ones.
                        .SelStart = .SelLength
                        'Return True on success
                        InsertAtCursor = True
                    End If
                End If
            End With
        End If
    Tuesday, June 14, 2016 6:12 PM
  • Have you tried stepping through the code to see what is going on? You might have to add a space after the close tags to make sure you are past them.

    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Tuesday, June 14, 2016 8:46 PM
  • if I put a line break <br> after  the line :

    If (Left(lijn, 6) = "TIMING") Then lijn = "<strong><u>" & lijn & "</u></strong><br>"

    then the formatting is right , but the problem is I don' t want a line break ...

    Tuesday, June 14, 2016 9:13 PM
  • the strange thing is , if you highlight and underline some text of a line in the textbox with the B-button and underline button

    <u></u> and <strong></strong> is used  ... 

    Wednesday, June 15, 2016 5:55 AM
  • Hi tekoko,

    I think this issue is caused by that if you end up with "</u></strong><br>", the Bold and Underline in the Text Formatting is checked for this memo field. I would suggest you add a non-formatted empty space within <div>, something like "<div><strong><u>test</u></strong> </div>".

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, June 15, 2016 6:47 AM
  • Works , But gives an extra line break ...
    Wednesday, June 15, 2016 1:27 PM
  • Hi tekoko,

    Which code you used? I made a test with below code, I only get an empty space instead of line break.

    Private Sub Command24_Click()
    Me.MemoField.SetFocus
    Me.MemoField.Text = "<div><strong><u>test</u></strong> </div>"
    End Sub

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by tekoko10 Thursday, June 16, 2016 6:01 AM
    Thursday, June 16, 2016 5:22 AM
  • yes ! the space is working ! many many thanks !

    the only strange thing is , if you type 1 character after the word "TIMING" , the underlining becomes 1 character longer  :)

    strange indeed , but never mind , it stays this way , problem solved !

    Thursday, June 16, 2016 6:03 AM