Results 1 to 5 of 5
  1. #1
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72

    Default text

    Hello everyone,

    I have a form in which I have a text field "OBSERVACIONES" (long text). In there, I want to set a default text which appears always when a new record is introduced and can be modified.
    I tried to write the whole text in "Default value" but it does not work.

    The text has a structure like this:



    text .... text:

    -text:
    -text:
    -text:

    text ... text.


    How can I solve this problem?

    Thank you in advance,

    Regards.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why did DefaultValue property not work? What did you try?

    "text .... text:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "-text:" & Chr(13) & Chr(10) & "-text:" & Chr(13) & Chr(10) & "-text:" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "text ... text."

    Otherwise, use VBA in form Current event to populate textbox.
    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.

  3. #3
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Thank you for answering, June7

    Firstly, my access level is not too high.

    I went to Field property in my table and set in "Default value", click at the 3 dots and copy the text between " "
    How do I proceed using VBA? Also i tried something like this:

    Code:
    Private Sub OBSERVACIONES_AfterUpdate()
    Me.OBSERVACIONES = " text:" _
    "-text:"_
    "text"_
    "text"
    
    End Sub

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Did you try the expression I show in prior post as DefaultValue?

    Don't use OBSERVACIONES AfterUpdate event. That will replace user edits.

    As I said, use form Current event. Only want field populated on a new record:

    If Me.NewRecord Then
    Me.OBSERVACIONES = " text:" & vbCrLf & "-text:" & vbCrLf & "text" & vbCrLf & "text"
    End If

    Understand that even if user does not edit, that text will still be saved to record.
    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.

  5. #5
    mar7632 is offline Advanced Beginner
    Windows 8 Access 2016
    Join Date
    Feb 2019
    Location
    Spain - Madrid
    Posts
    72
    Hello!

    I have solved the problem in a different way.

    What I did was to create a new table called "Table" and with a field called "texto", in there I have copied the whole text I needed.

    On the other hand, I have a form in which the field OBSERVACIONES is in there and then I´ve introduced this:

    Code:
     Private Sub Form_Current()
    
                    If Me.NewRecord Then Me.OBSERVACIONES = Dlookup ("texto", "Table")
    
    End Sub
    By using this code when a new record is introduced, the long text appears in OBSERVACIONES and can be modified and keep it.

    Regards.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-25-2017, 10:04 PM
  2. Set default value in text box
    By shaunacol in forum Forms
    Replies: 4
    Last Post: 06-12-2015, 09:05 AM
  3. Replies: 12
    Last Post: 03-01-2015, 01:36 PM
  4. create default rich text in text box
    By enemydr in forum Forms
    Replies: 7
    Last Post: 02-19-2014, 09:38 PM
  5. Background Text (Not Default)
    By Douglas Post in forum Forms
    Replies: 1
    Last Post: 02-16-2012, 08:43 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