Results 1 to 4 of 4
  1. #1
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186

    Properties vbCrlf and CHR(13) & CHR(14) to create into a List into a Textbox

    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 access app is to record customer complaints. In this textbox is just added people that participate into the problem solution of this specific complaint, I mean my main table has diffente fiels like ID, Date_Start, Date_End, Issue_Reported, and some more... one of this is "TeamWork" which include the "names of the people" working on that specific issue; such are not really important data to query further, is just to "know" who were working on it)


    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

    'Enclosed is the example... I hope somebody could help
    Example of database list.zip

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Try this.
    It replaces the entire code behind the form.

    Edit: found a bug. See red code at bottom.

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub WT_Quality_Click()
        Dim Quality As String
        Quality = DLookup("[Name]", "[TeamWork]", "[Department]= 'Quality'")
        If Me.WT_Quality = -1 And Len(Me.TeamWorktxt & vbNullString) = 0 Then
            Me.TeamWorktxt = Quality
        ElseIf Me.WT_Quality = -1 And Me.TeamWorktxt <> "" Then
            Me.TeamWorktxt = Me.TeamWorktxt & vbCrLf & Quality
        End If
        If Me.WT_Quality = 0 Then
            If InStr(Me.TeamWorktxt, vbCrLf & Quality) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, vbCrLf & Quality, "")
            ElseIf InStr(Me.TeamWorktxt, Quality) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, Quality, "")
            End If
            Call Blankit
        End If
    End Sub
    
    
    Private Sub WT_Process_Click()
        Dim Process As String
        Process = DLookup("[Name]", "[TeamWork]", "[Department]= 'Process'")
        If Me.WT_Process = -1 And Len(Me.TeamWorktxt & vbNullString) = 0 Then
            Me.TeamWorktxt = Process
            ElseIf Me.WT_Process = -1 And Me.TeamWorktxt <> "" Then
            Me.TeamWorktxt = Me.TeamWorktxt & vbCrLf & Process
        End If
        
        If Me.WT_Process = 0 Then
            If InStr(Me.TeamWorktxt, vbCrLf & Process) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, vbCrLf & Process, "")
            ElseIf InStr(Me.TeamWorktxt, Process) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, Process, "")
            End If
            Call Blankit
        End If
    End Sub
    
    
    Private Sub WT_Production_Click()
        Dim Production As String
        Production = DLookup("[Name]", "[TeamWork]", "[Department]= 'Production'")
        If Me.WT_Production = -1 And Len(Me.TeamWorktxt & vbNullString) = 0 Then
            Me.TeamWorktxt = Production
            ElseIf Me.WT_Production = -1 And Me.TeamWorktxt <> "" Then
            Me.TeamWorktxt = Me.TeamWorktxt & vbCrLf & Production
        End If
        If Me.WT_Production = 0 Then
            If InStr(Me.TeamWorktxt, vbCrLf & Production) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, vbCrLf & Production, "")
            ElseIf InStr(Me.TeamWorktxt, Production) > 0 Then
                Me.TeamWorktxt = Replace(Me.TeamWorktxt, Production, "")
            End If
            Call Blankit
        End If
    End Sub
    
    
    Private Sub Blankit()
        If WT_Production = 0 And WT_Quality = 0 And WT_Process = 0 Then
            Me.TeamWorktxt = ""
        End If
        If Left(Me.TeamWorktxt, 2) = vbCrLf Then
            Me.TeamWorktxt = Replace(Me.TeamWorktxt, vbCrLf, "", 1, 1)
        End If
    End Sub
    Last edited by davegri; 05-07-2020 at 04:19 PM. Reason: bug

  3. #3
    Uncle Gizmo is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    26
    You put the team worker participants "names of the people" in a separate table like attached. Using a subform on the main form to store the "names of the people"
    Attached Files Attached Files

  4. #4
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186
    Good alternative!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-15-2020, 05:24 PM
  2. list of properties working with outlook.
    By Homegrownandy in forum Programming
    Replies: 3
    Last Post: 03-13-2020, 09:43 AM
  3. Replies: 6
    Last Post: 11-24-2018, 02:25 PM
  4. Replies: 3
    Last Post: 02-01-2018, 03:10 AM
  5. Replies: 0
    Last Post: 09-23-2009, 10:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums