Results 1 to 8 of 8
  1. #1
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305

    Button to add defined text line to a long-text field

    Bit of an odd question and I haven't been able to find a guide online. I've a database full of customer complaints and a form that looks at each complaint one at a time.



    There's a "follow-up" field where I add in all my notes for the complaint like "left message to talk with customer", etc.

    The last line of the field always needs to state "11/12/2021: Complaint closed. This has been addressed with the customer."

    It's kind of a pain to always type out. I was hoping I could just add a button that, when pressed, automatically drops in that line into the field. Any idea?

    I've added an example DB to help show what I'm working with.

    Example.accdb

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    That should be easy to do. You need to check if the follow-up field already has the "Complaint closed" string in it and if not add the line:
    Code:
    If Instr(Me.txtFollowUp,"Complaint closed")=0 then 
         Me.txtFollowUp =Me.txtFollowUp & vbcrlf & Date() & ": Complaint closed. This has been addressed with the customer."
    End If
    Me.txtDateClosed=Date()
    Me.Dirty=False 'save the record
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The term won't be there if it's part of the sentence that you want to append so no point in looking for it?
    Make a string variable (strResponse ? ) = the entire contents of the field; e.g. strResponse = Me.txtMyControlName.
    Then write
    strResponse = strResponse & vbCrLf & Date & ": Complaint closed. This has been addressed with the customer."

    That assumes you want a line wrap for the ending. If not, remove the vbCrLf
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    My idea was to not append it if the complaint was already closed as if there are lots of lines the text box might not be tall enough to display the last line that would hold the ...Complaint closed... line.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The last line of the field always needs to state "11/12/2021: Complaint closed. This has been addressed with the customer."
    It's kind of a pain to always type out. I was hoping I could just add a button that, when pressed, automatically drops in that line into the field.
    Guess we'll have to wait for clarification, because I interpret those comments to mean that the line won't be there, thus Instr won't find "Complaint closed".

    EDIT - Sorry Vlad, I didn't thoroughly read what you posted and you are spot on. I've not been concentrating as much as I should lately. The only thing I dare to add is that not always does the user want a date stamp equal to the current date. If the action was taken on previous day/shift that might be the date that should be there and not the current date. However, you gave what was asked for and rightly so.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Quote Originally Posted by Gicu View Post
    That should be easy to do. You need to check if the follow-up field already has the "Complaint closed" string in it and if not add the line:
    Code:
    If Instr(Me.txtFollowUp,"Complaint closed")=0 then 
         Me.txtFollowUp =Me.txtFollowUp & vbcrlf & Date() & ": Complaint closed. This has been addressed with the customer."
    End If
    Me.txtDateClosed=Date()
    Me.Dirty=False 'save the record
    Cheers,

    So sorry about the delay in response. This worked perfectly. One small question....is it possible for the text to have a line break in it when inserted? I.e.:


    Complaint closed. This has been addressed with the customer.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    try
    ": Complaint closed." & vbCrLf & "This has been addressed with the customer."
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    That worked!! Thanks so much. This is a huge time saver

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

Similar Threads

  1. Replies: 5
    Last Post: 10-27-2021, 07:11 PM
  2. How can I import long text with line breaks from .XML
    By PeterG in forum Import/Export Data
    Replies: 3
    Last Post: 07-11-2020, 03:54 PM
  3. Replies: 8
    Last Post: 01-07-2020, 12:28 PM
  4. Replies: 4
    Last Post: 11-04-2019, 06:53 PM
  5. Replies: 24
    Last Post: 03-12-2019, 08:02 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