Results 1 to 6 of 6
  1. #1
    hinsdale1 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2013
    Posts
    63

    Temp text (instruction or label) in the text box that disappears?

    Is it possible to place temp text (instruction or label) in the text box that disappears when user clicks the box in order to enter text?

    Any help would be most appreciated!





    I am sure this has been asked and answered before, so I apologize, but can't seem to come up with the appropriate search terms to find the solution.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Is it a bound or unbound test box?
    I think you will probably want to use the "OnClick" event procedure, which is VBA code that is automatically invoked when that text box is selected. You can make it delete whatever is in that text box when it is clicked.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Not advisable for bound controls unless you build validation code to prevent saving record with the 'temp' text. Also, if the field is number or date type, cannot have text value in the control.

    Can use DefaultValue property for displaying initial value.
    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.

  4. #4
    hinsdale1 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2013
    Posts
    63
    Thank you for the replies.. you have steered me in the right direction. Still experimenting.. so will likely follow up with a question or two.

  5. #5
    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 kind of thing will accomplish the task:
    Code:
    Private Sub LastName_GotFocus()
     If Nz(Me.LastName, "") = "" Then
      Me.LastName = "Enter Last Name"
     Else
      Me.LastName = Me.LastName
     End If
    End Sub
    
    Private Sub LastName_LostFocus()
     If Me.LastName = "Enter Last Name" Then
      Me.LastName = Null
     Else
      Me.LastName = Me.LastName
     End If
    End Sub
    I've tested this fairly extensively, without causing it to break. If anyone can find a problem with it I'd love to hear from them.

    As was previously mentioned, you can only do this with a Field that is defined as Text. But keep in mind, though, that things like ID 'numbers,' telephone 'numbers,' etc., can be defined as Text!

    A Field really only has to be defined as a Number Datatype if it is going to be used in mathematical calculations or if it is being used as a Foreign Key to link to a Table whose Primary Key is an Autonumber.

    Linq ;0)>

  6. #6
    hinsdale1 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2013
    Posts
    63
    Thanks for all the replies . Sidetracked by other hurdles so haven't quite completed this sub but pretty sure you have me heading in the right direction. Thanks again.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  2. Update Label from Text Box
    By rcdeck in forum Forms
    Replies: 2
    Last Post: 01-30-2013, 11:22 AM
  3. click label -> append text to texbox
    By cnstarz in forum Access
    Replies: 5
    Last Post: 06-15-2011, 06:09 AM
  4. Replies: 1
    Last Post: 04-29-2010, 05:15 PM
  5. Replies: 1
    Last Post: 03-29-2009, 08:27 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