Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Unhappy Unanswered: Problem with MsAccess List Control

    While adding a string containing coma(,) using addItem Method the sting gets split into twp items. Any solutions for this.It is urgent?
    Sree

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Question

    I have a list box called lstNames which takes its contents form a textBox called txtName

    I put this


    Private Sub txtName_LostFocus()
    ···lstNames.AddItem (txtName.Text)
    End Sub

    and it taks values with , if you give them in the text box



  3. #3
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Unhappy

    My problem is different

    I am adding a string "ABCD,EFGH" and it gets added in second string as
    "ABCD"
    "EFGH"

    As two items

    Iwant to retain the coma in the list


    Originally posted by hammbakka
    I have a list box called lstNames which takes its contents form a textBox called txtName

    I put this


    Private Sub txtName_LostFocus()
    ···lstNames.AddItem (txtName.Text)
    End Sub

    and it taks values with , if you give them in the text box


    Sree

  4. #4
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Smile

    Originally posted by sreeraj
    My problem is different

    I am adding a string "ABCD,EFGH" and it gets added in second string as
    "ABCD"
    "EFGH"

    As two items

    Iwant to retain the coma in the list
    Try strList = """ABCD,EFGH"""
    List.AddItem strList

    Gregg

  5. #5
    Join Date
    Oct 2003
    Location
    India
    Posts
    55

    Thumbs up

    Thanx guys for the help any how i have myself found a solution if interested please check it !


    This was the data available in table dd

    Apple,Orange
    Grape,Pine
    Guava,Moosambi
    ----------------------------------------

    When this was added to list through query it was populated properly
    but when from one list to another using addItem Method
    the data would be like this
    Apple
    Orange
    Grape
    Pine
    Guava
    Moosambi
    Becs the addItem method was considering , as a separator

    The Solution i have found is

    as below

    List7 is source list
    and list12 is target list


    Private Sub Command9_Click()
    Dim OCN As New ADODB.Connection
    Dim RS As New ADODB.Recordset
    Dim sql As String
    sql = ""
    For i = 0 To List7.ListCount - 1
    If List7.Selected(i) = True Then
    sql = sql & " or items='" & Trim(List7.Column(0, i)) & "'"
    End If
    Next i

    sql = Mid(Trim(sql), 3, Len(sql) - 2)
    sql = "SELECT * FROM DD WHERE " & sql
    List12.RowSource = sql


    End Sub
    Sree

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •