Results 1 to 9 of 9
  1. #1
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24

    Adding more than one pre-written statement to the same Text Box

    I'm not sure what you would call what I want to do so Ill try and explain it.

    I know I can add a pre-written statement to a Text Box by using Me.TextBoxName.Value = "what I want written in there"



    But what I want to be able to do in a Long Text Box, is to be able to add multiple pre-written statements without removing the other line already in there, and each new statement be staring on a new line, like is if I pressed enter after the last statement.

    Even if someone wants to tell me what the action I am trying to do is called I will try and find the solution myself.

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Its called concatenation.
    If for example you have 3 text strings
    Str1= "Hello world."
    Str2 ="Bazooka"
    Str3 ="Goodbye"
    Then you can use Me.Textbox.Value = str1 & str2 & str3
    The .Value is optional as its the default property
    if you want spaces and/or full stops between each item, then
    Me.Textbox= str1 & " " & str2 & ". " & str3
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24
    Ok Ill look into it thanks

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,939
    if your textbox already has text in it and you want to append use

    Me.Textbox.Value = Me.Textbox.Value & str3

    or

    Me.Textbox.Value = str3 & Me.Textbox.Value

    depending on whether str3 text is to appear at bottom or top

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    p.s. You stated in your original post you wanted the 'result' field to be long text. Manipulating long text fields is notoriously difficult and you may find no matter what you do your 'long text' field is going to start lopping of characters after the 255th place. Be forewarned!

  6. #6
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24
    using @ajax solution I have got this to work how I want it

    Me.testbox.Value = Me.testbox.Value & vbCrLf & "testmore"

    So far no issues as warned by @rpeare ...............so far

    now the next challenge to insert accumulating numbers in front of each line.

  7. #7
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24
    actually that was easier than I thought
    I added another cell called 'testnumber' to store a number in and then used the code below

    Dim num As String
    Dim netnum As String


    num = testnumber
    netnum = num + 1
    If Me.testnumber.Value = 0 Then
    Me.testbox.Value = Me.testbox.Value & netnum & ". " & "testmore"
    Else
    Me.testbox.Value = Me.testbox.Value & vbCrLf & netnum & ". " & "testmore"
    End If
    Me.testnumber = netnum

  8. #8
    Join Date
    Apr 2017
    Posts
    1,792
    Of-course you can do as you like, but when you save some test data in such way, then I don't see any difference when you simply delete and forget those data! When you really have lot of test results stored in this way, then it will be practically impossible to make any data mining or analyze on your table!

    What is the reason you didn't choose more conventional way to store those data? E.g. you have tables:
    tblDevices: DeviceID, DeviceName, ...
    tblDeviceTests: TestID, DeviceID, [DeviceTestNo], TestResult

    Now, when you have e.g. form where you select a device and can see info about this device (fDevices), you can have a continuous subform in it with all test results for this device (you link the form and subform through DeviceID). Even more, registering new test results is then done simply adding a new record into subform - it will be automatically linked with active device.
    And whenever you want e.g. count specific result for given device, or for all devices, or for specific device class, or over certain time period - a simple report based on simple query will do that without a need for heavy coding.

  9. #9
    PBCN is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Posts
    24
    I think I understand what you are saying, having a filtered continuous subform from another table on the form showing each individual line, which is what I intend to do with some parts of the overall app.

    But the data ill will be using in these cells is basically data that is only going to be inserted into reports, which then are handed onto other people to tell them "xyz". Its not data that I will need to look up/analyze later on.

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

Similar Threads

  1. adding an iff statement as criteria in dcount
    By Thompyt in forum Programming
    Replies: 6
    Last Post: 02-24-2018, 09:29 AM
  2. Adding Exceptions to SQL's ORDER BY Statement
    By ohmydatabase in forum Access
    Replies: 9
    Last Post: 08-23-2017, 02:27 PM
  3. Adding if statement
    By bradp1979 in forum Queries
    Replies: 9
    Last Post: 12-28-2015, 05:36 PM
  4. Replies: 2
    Last Post: 05-08-2014, 06:20 AM
  5. Replies: 10
    Last Post: 08-25-2012, 03:25 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