Results 1 to 6 of 6
  1. #1
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110

    Use List box to populate text box with existing text

    Hello all,

    I'm working on a form named frmJobNote that will be a daily diary for project managers for their jobs. My goal is to have them press a command button on another from that opens frmJobNote in continuous form view. There would only be one text box, txtJobNote. I hope to have the current date populate the txtJobNote when frmJobNote is opened. The project manager would then write any notes they have after the date. Then they would use list box lbxEquipment to select the equipment that was on the job that day. The equipment would be entered after the project managers notes.
    Currently I'm using the following code I found thanks to AccessForums.net.


    Code:
    Private Sub lbxEquip_Click()Dim strSelected As String
    Dim varItem As Variant
    Dim ctl As Control
        With Me.lbxEquip
            For Each varItem In .ItemsSelected
                strSelected = strSelected & "," & .ItemData(varItem)
            Next varItem
            Me.txtNotes = Mid(strSelected, 2)
        End With
    End Sub
    This code works great, but It deletes the text already in txtJobNote and records column(0) when I would like it to record column(1) and column(2).

    Could anyone give me advice on getting a list box populate a text box after the text already existing as well as record my second and third column?

    Thank you for having a look,

    John

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You can get at the columns with:

    .Column(x, varItem)

    where x is the desired column, zero based. You can add to the textbox the same way you add to strSelected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Hmmm. You have to store the data in a table if it is to persist/exist after you close your session.

    If your notes are always less than 250 chars, then a short text field would suffice.

    You could default the value of the field to Now, then when the user adds data, you could concatenate the new data to the existing
    eg: 07-Oct-2016 7:35PM & " " & "this is where the note text goes"

    You might want a table of subjects or categories to simplify user input to help with any reporting/querying.

    Just some thoughts for consideration.
    Good luck.

  4. #4
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    Thank you for the fast response.

    I appreciate the help. I'm going to see if I can finish putting this thing together.

    Thanks,

    John

  5. #5
    Stephenson is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    North West
    Posts
    110
    Thanks again pbaldy and orange.

    pbaldy, I was able to expand on the code I found that you had originally posted and with the help you gave me in this post. Thank you very much!

    orange, I took your suggestion for my tables. This makes much more sense than what I was attempting to do.

    Thanks for the awesome help!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Populate Text Box With Selected Value From List Box
    By chalupabatman in forum Forms
    Replies: 27
    Last Post: 08-17-2016, 06:24 AM
  2. One text box populate another text box?
    By Xterra14s in forum Access
    Replies: 1
    Last Post: 07-26-2016, 01:56 PM
  3. Populate text box by clicking on a text box
    By Derrick T. Davidson in forum Programming
    Replies: 1
    Last Post: 02-03-2016, 05:56 AM
  4. Replies: 7
    Last Post: 06-05-2015, 11:13 AM
  5. Replies: 2
    Last Post: 06-11-2012, 09:37 AM

Tags for this Thread

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