Log in

View Full Version : Properties vbCrlf and CHR(13) & CHR(14) to create into a List into a Textbox



charly.csh
05-07-2020, 12:22 PM
Hi everyone

I hope somebody could help me with this...

I'm writing into a textbox with my code a "List of people" depending on some Checkboxes. (The name of the textbox is TeamWorktxt) and the checkboxes are WT_Quality, WT_Production, WT_Warehouse, WT_Process.

If I l click on one it adds the name of the guy responsible of the "area" and after this addition I am also using the VbCrLf to "create" an "Enter" effect... it gives the appearance into the big textbox like a "list"

The issue is when unclick on this check box an use the property REPLACE and CHR(10) or CHR(13) it deletes all the "blank" spaces and the list lose its structure. What I want is just to clean the line created or "undo" my "Enter"

I do not know if there is just a property to eliminate just a "line" and not all the blank spaces

I highly appreciate your support

My code

'****************************************
Private Sub WT_Quality_Click()

If Me.WT_Quality = -1 And Len(Me.TeamWorktxt & vbNullString) = 0 Then

Me.TeamWorktxt = DLookup("[Name]", "[TeamWork]", "[Department]= 'Quality'")

ElseIf Me.WT_Quality = -1 And Me.TeamWorktxt <> "" Then

Me.TeamWorktxt = Me.TeamWorktxt & vbCrLf & DLookup("[Name]", "[TeamWork]", "[Department]= 'Quality'")

End If

If Me.WT_Quality = 0 Then

Dim Quality As String
Quality = DLookup("[Name]", "[TeamWork]", "[Department]= 'Quality'")

'Here is my issue, I am sure if this is the best way to do this...

Me.TeamWorktxt = Replace(Me.TeamWorktxt, Quality, "")
Me.TeamWorktxt = Replace(Me.TeamWorktxt, Chr(10), "") 'Chr(10)
Me.TeamWorktxt = Replace(Me.TeamWorktxt, Chr(13), "") 'Chr(13)

End If

End Sub

OBP
05-08-2020, 06:17 AM
Personally I prefer to use a Memo field rather than a text box, unless the text is not going to be saved.
As the data is held in a String I use a string and string functions to manipulate the data.
Left, Right, Mid, Len and instring which give you total control of the string.
You can manipulate the string and use a msgbox to show the results to refine it before assigning it to the text box or memo box.