Results 1 to 4 of 4
  1. #1
    randle is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    7

    Information text on unbound text box


    Hi,

    I want to do the same as what can be found here https://www.accessforums.net/forms/t...ars-34365.html however, I'd like the unbound text box to show this informational text all the time unless it has taken focus.

    I'd also like to be able to format this text ie. font type, size, style etc. which I imaging can again be specified through the code!?

    One other thing I've noticed is that when clicking in the text box the informational text doesn't disappear and instead lets you add to this text at the position of the cursor. In the ideal world I simply want it to disappear when focus is gained so that when you start typing, this is the only text that's shown.

  2. #2
    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
    I think this meets your requirement, but note that it can only be used on a Single View Form, not on a Datasheet or Continuous View Form. It uses a super-imposed Label, for the display text, and can be formatted by simply selecting the Label and using the Formatting Tab on the Ribbon/Menu

    • Delete the Textbox’s attached Label
    • Create new Label for Textbox with the Caption of choice
    • Set BackStyle and BorderStyle of the Label to Transparent
    • Position Label inside of the Textbox

    Now, use this code, replacing TargetFieldLabel and TargetField with the actual names of your Controls:

    Code:
    Private Sub Form_Current()
    
    If Nz(Me.TargetField, "") <> "" Then
      TargetFieldLabel.Visible = False
    Else
      TargetFieldLabel.Visible = True
    End If
    
    End Sub


    Code:
    Private Sub TargetField_GotFocus()
     
      TargetFieldLabel.Visible = False
    
    End Sub


    Code:
    Private Sub TargetFieldLabel_Click()
    
      TargetField.SetFocus
    
    End Sub


    Code:
    Private Sub TargetField_LostFocus()
    
    If Nz(Me.TargetField, "") <> "" Then
      TargetFieldLabel.Visible = False
    Else
      TargetFieldLabel.Visible = True
    End If
    
    End Sub


    Linq ;0)>

  3. #3
    randle is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    7
    What a legend. Thanks so much. Works a treat...and first time!!

  4. #4
    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
    Glad we could help!

    Linq ;0)>

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

Similar Threads

  1. Replies: 2
    Last Post: 06-11-2012, 09:37 AM
  2. Unbound Text
    By cbrsix in forum Reports
    Replies: 16
    Last Post: 10-27-2011, 01:27 PM
  3. Unbound Text boxes
    By kyleg222 in forum Forms
    Replies: 2
    Last Post: 08-02-2011, 12:53 PM
  4. Unbound Text box in reports
    By Overdive in forum Reports
    Replies: 1
    Last Post: 02-17-2010, 09:52 AM
  5. Unbound text box truncating text
    By gddrew in forum Forms
    Replies: 0
    Last Post: 03-02-2006, 11:26 AM

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