Results 1 to 15 of 15
  1. #1
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43

    Entering New Line Before Comment

    Hi Everyone,

    I'm new to access and to vba for access. I found the following code that I have used in my modified Issues Template that MS offers with Access. The code allows me to add new comments to an existing list of comments, unfortunately I dont know how to make the code automatically add a blank line before adding a new comment.

    I have tried eiditing the code by adding vbCrLf and vbNewLine to the bold portion of the code below

    Private Sub IndirectDataInput_Click()
    If IndirectDataInput.Caption = "New Comment" Then
    TempDataBox.Visible = True
    TempDataBox.SetFocus


    IndirectDataInput.Caption = "Save Comment"
    Else
    IndirectDataInput.Caption = "New Comment"
    If IsNull(Me.Description) Then
    If Len(Me.TempDataBox) > 0 Then
    Me.Description = Now() & "" & Me.TempDataBox
    Me.TempDataBox = ""
    TempDataBox.Visible = False
    Else
    TempDataBox.Visible = False
    End If
    Else
    If Len(Me.TempDataBox) > 0 Then
    Me.Description = Me.Description & Now() & Me.TempDataBox
    Me.TempDataBox = ""
    TempDataBox.Visible = False
    Else
    TempDataBox.Visible = False
    End If

    End If
    End If
    End Sub

  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
    vbCrLf should work. How did you use it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43
    Thank you for your reply. I tried multiple methods (because I'm not familiar with VBA, I messed around with it to see if I could get it to do what I wanted, but no luck).

    Here is a sample of what I've tried:

    Me.Description = Me.Description & vbCrLf & Now() & Me.TempDataBox

    Result: this resulted in the following, which is space in front of the date, but not an entire blank row.
    Click image for larger version. 

Name:	Image of VBA Code Change.PNG 
Views:	34 
Size:	3.0 KB 
ID:	20194

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    So add 2 of them.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43
    Thanks for the suggestion, but here's what happened.

    The result of this code: Me.Description = Me.Description & vbCrLf & vbCrLf & Now() & "" & Me.TempDataBox

    Was one blank row, however, entering a second comment did not begin with a blank row.

    Click image for larger version. 

Name:	Two vbCrLf.PNG 
Views:	33 
Size:	4.0 KB 
ID:	20200

  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
    I'm confused, as it clearly added the line. You can put it in a different place if you want. Or is this because of previous tests and you need to start over?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If comments were in a related table (each comment would be a new record), no VBA would be needed for data entry.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    While you are typing in a text box, pressing "<ctl>m" (the control key and the letter m) adds a vbcrlf to the text. No code necessary.

  9. #9
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by pbaldy View Post
    Or is this because of previous tests and you need to start over
    I wondered about this, too! I wrote this code a few years ago, and just retrieved it and made the change you need, and it works as it should. I'd delete your current data from the Memo Field and start over; if it still doesn't function correctly post the entire Sub, as it is now written.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43
    Quote Originally Posted by June7 View Post
    If comments were in a related table (each comment would be a new record), no VBA would be needed for data entry.
    Thanks for the suggestion. I should provide a bit of background. I created this database to track tasks/issues/small projects at work. My company is not using a CRM system and being in a client facing role I need a system that will help me keep track of the various interactions I have with customers, internal staff, and others to ensure nothing falls through the cracks.

    So far I have used an older version of the issues template that MS offers as a base case to learn from and modify for my needs. The latest copy is made for web databases and is difficult to dissect. I'm not very good with MS Access therefore I dont want to rely on someone else's code because when it breaks down I have no idea how to fix it.

    I like your idea about using a separate table. I have uploaded my database to show you how I have set it up. Perhaps you can help me understand how to make the Comments table record a sequence anytime I enter a new comment relating to one project/task.

    I learned a bit about how to add a separate table for comments from this video, but I'm not sure how to make it work with my input form. https://www.youtube.com/watch?v=gEUiousVDqY
    Attached Files Attached Files

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Consider a subform for Comments on the ProjectDetails form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would advise not using an autonumber field for the customer number. Create another field in the customer table for the customer number and use a "Custom Autonumber" to create the number.

    See Custom Autonumbers/sequential numbers
    http://baldyweb.com/CustomAutonumber.htm

    Same for the Comments table. You don't need a compound PK. Just a custom autonumber for the SquenceNo field. (keep all of the PK - FK relationships the same)


    My $0.02.........
    Good luck with your project..

  13. #13
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43
    Quote Originally Posted by ssanfu View Post
    I would advise not using an autonumber field for the customer number. Create another field in the customer table for the customer number and use a "Custom Autonumber" to create the number.

    See Custom Autonumbers/sequential numbers
    http://baldyweb.com/CustomAutonumber.htm

    Same for the Comments table. You don't need a compound PK. Just a custom autonumber for the SquenceNo field. (keep all of the PK - FK relationships the same)


    My $0.02.........
    Good luck with your project..

    Thank you for helping me with this. I think I'm almost there...

    I removed the customers table entirely, I will use combo boxes as these records dont change much.

    There are now 3 tables, tblContacts, tblMemos, and tblProjects.

    The tblContacts with tblProjects is now joined using a 1-M relationship. I did the same for the tblProjects with tblMemos. In the tblMemos I added an AutoNumber key called MemoSequenceID. The layout looks great and functions much better because each Memo is in a separate row.

    To make the form look cleaner I tried using this code from http://allenbrowne.com/func-concat.html. Unfortunately, I hit a bunch of snags, so I'm hoping someone can give some advice.

    Does anyone have an alternative way of organizing the Memos on the form, or is the subform the best/only way to do this? In my case, the subform isnt the best way to present a Memo that contains 1 or more paragraph of text.

    Thanks,

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Allen Browne's ConcatRelated function is intended to use with outputting data to a report, not a form.

    Use form/subform for inputting data and report for manipulating output.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Sunny8760 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    43
    Quote Originally Posted by June7 View Post
    Allen Browne's ConcatRelated function is intended to use with outputting data to a report, not a form.

    Use form/subform for inputting data and report for manipulating output.
    Great. Thanks for your help.

    Regards,

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

Similar Threads

  1. Replies: 2
    Last Post: 03-23-2015, 08:32 AM
  2. Replies: 1
    Last Post: 11-11-2014, 03:54 PM
  3. Replies: 10
    Last Post: 06-10-2014, 09:03 AM
  4. Replies: 7
    Last Post: 04-11-2011, 03:58 PM
  5. Replies: 2
    Last Post: 10-11-2010, 03:15 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