Results 1 to 12 of 12
  1. #1
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19

    Selected Multi Fields Added a textbox with Comma

    Hello,
    I have a employee facility form which we have many Facilities Item available. When you click the Items field it will open the Items List Continues form and you can selection which Items you want to added.


    So, I have create all of form, needs your assist. for HOW i will add this in the items text box multi data with comma,
    Attached Thumbnails Attached Thumbnails CaptureF.png  

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you need to loop through the frmFacilityItems recordset and add to a string where the checkbox is true - or investigate using the concatRelated function (google it)

    Basic code might be something like

    Code:
    dim s as string
    with me.recordset
        .movefirst
        while not .eof
            if .chkSelected then s="," & fItem & s
            .movenext
        wend
    end with
    if s<>"" then s=mid(s,2)
    you can then assign s to your items list control

  3. #3
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    Hello Ajax,
    Thank for your reply. But it was error.
    "Runtime Error 438"

    Code:
    Private Sub cmdInsData_Click()Dim s As String
    With Me.Recordset
        .MoveFirst
        While Not .EOF
            If .chkSelected Then s = "," & FacilityItems & s
            .MoveNext
        Wend
    End With
    If s <> "" Then s = Mid(s, 2)
    And this is mark Code
    Code:
        Dim strIDs As String
    
        strIDs = Me!Text1 & vbNullString
        If Len(strIDs) = 0 Then
            strIDs = "," & Me!Id & ","
        
        Else
    
    
            If InStr(1, strIDs, "," & Me!Id & ",") > 0 Then
                'remove it
                strIDs = Replace(strIDs, "," & Me!Id & ",", "")
            Else
        
                strIDs = strIDs & "," & Me!Id & ","
            
            End If
            strIDs = "," & strIDs & ","
            Do Until InStr(1, strIDs, ",,") = 0
                strIDs = Replace(strIDs, ",,", ",")
            Loop
            If Right(strIDs, 1) <> "," Then strIDs = strIDs & ","
            If Left(strIDs, 1) <> "," Then strIDs = "," & strIDs
            If strIDs = "," Then strIDs = ""
            
        End If
        Me!Text1 = strIDs
        Me.Refresh
    
    
    End Sub
    I dont know where is the problem.

  4. #4
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    Concat = i dont know much.
    I try:
    Code:
    NumberList(", ",me.txtItems)
       If Me.FacilityItems = 0 Then
           Me.FacilityItems = NumberList(",", Me.Id)
       End If
    but not work.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    not enough information - what is the description of error 438? what line is highlighted where the error occurred? The code I provided is an example. I have no idea what you called your fields so you need to change them to whatever you called them. Also no idea what 'mark code' is all about

  6. #6
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    Okay. I have attached my DB
    Attached Files Attached Files

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    there is no code on the click event of the button.

    please provide the error description and identify which line is highlighted

  8. #8
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    Quote Originally Posted by Ajax View Post
    there is no code on the click event of the button.

    please provide the error description and identify which line is highlighted
    it was give error in While .......... wend Loop Statement
    after I try to
    Code:
    Debug.Print s
    No nothing...
    Attached Thumbnails Attached Thumbnails Capture2.JPG  

  9. #9
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Wouldn't a multi-select listbox be easier?

  10. #10
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    Hello J. Woolley,
    How are you?
    can you help me please?

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Is this what your trying to do?
    Attached Files Attached Files

  12. #12
    smtazulislam is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2020
    Posts
    19
    omg! so many code you would created for me. Thank you so much, I appreciated J. Woolley.

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

Similar Threads

  1. Replies: 5
    Last Post: 02-04-2017, 07:34 AM
  2. Multi selected combo box
    By jcrump230 in forum Access
    Replies: 2
    Last Post: 08-19-2014, 05:57 AM
  3. Replies: 1
    Last Post: 04-16-2014, 07:28 PM
  4. Replies: 11
    Last Post: 04-22-2013, 04:21 PM
  5. Replies: 1
    Last Post: 08-17-2010, 02:33 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