Results 1 to 6 of 6
  1. #1
    LostInAccess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6

    Transparent text box title on Form?

    Hey folks,

    I have a Form with multiple text boxes and several combo boxes (which autofill said text boxes). I would like to know how to have the title of each text box displayed within the actual field on the Form, but then disappear once that field has been filled. I have tried several "Property Sheet" combinations but still can't get the text box title to disappear.

    The idea is to have a Form that can be printed with only the fields displayed, yet I need to have the title of each field visible initially so that the user knows what information is being filled.

    Is this possible? Is VB required? If so, I'm gonna need some guidance.

    Thanks a ton.
    Jon

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,508
    You want the label to not be visible if associated textbox has value?

    Need VBA to set Visible property of the label control.

    The trick is figuring out what event(s) code needs to be in. Is this a bound form? Are the textboxes bound to fields? Will the form open to an existing record with data displayed in textboxes? Is this form in Single or Continuous View?
    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
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    2,949
    It can be done, but it takes a lot of work and code, because of the events June7 mentioned! And it can only really be done for a Single View Form.
    • Delete the Textbox’s attached Label
    • Create new Label for Textbox
    • Name the new Label something appropriate
    • Enter your Caption for the new Label
    • Set BackStyle and BorderStyle to Transparent
    • Position the Label in the Textbox

    Now, use this code

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

    And this has to be done for each Textbox!

    If the Form is Unbound, you can omit the Form_Current event.

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

    All posts/responses based on Access 2003/2007

  4. #4
    LostInAccess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6
    Thanks for the quick response guys.

    June7- I'm not entirely sure about the bound/unbound(ness). I created the Form from Form Design using unbound text boxes, but then used the DLookup function for each text box that relates back to it's governing Combo box. So I am not sure if that DLookup function then makes my fields bound or not.
    It is in single view, so no problem there. But I would like to save each Form once completed and move to a new one if it is possible.

    Linq- Thanks for the code, although I'm not having any luck with it. I am pretty new, so it is entirely possible that i'm not executing it properly (ie, making the correct changes for my db). When I enter your code (swaping in my label name "operator" in lieu of "targetfield", is that right?) nothing appears to change. On the plus side, I don't get any error messages. However it would be nice if i could get it to function.
    The Form has each field autofilled, so the User won't be typing or clicking in any of the text boxes (except for the initial drop down combo boxes). I'm not sure if that makes a difference in the code you posted or not? I am also not appose to having to enter the code many times, if i can get the code right.

    Any more help would be much appreciated.
    Thanks again guys.

    Jon

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,508
    TargetField should be the name of the box, not its associated label.

    A form is bound if it has a RecordSource.

    Data controls are bound if their ControlSource is a field of the RecordSource, not an expression such as the DLookup.

    Why are you using DLookup? Domain aggregate functions can be slow. There are other ways to get data on the form that might be better for your situation.

    If users are not doing data entry/edit, why are you using a form and not a report? The norm is forms for on-screen view, reports for print 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.

  6. #6
    LostInAccess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    6
    Thanks,

    June7 - The Users will be using the Form for some data entry (2 fields), but the rest is autofilled once they make the selection from the drop-down combo box. That code does work well for the fields that need to be filled out by the users (thanks Linq). As for the rest of my fields, I will just squeeze the label in the space and change the "Display When" property to not have it print out.

    The DLookup appeared to be my best option since my Form has three separate areas, each containing multiple fields built on different queries, which were all drawing from the same Table. But again, I'm pretty new to this, I'm sure there are other options to obtain the same result. As for the 'slow' factor, my db is very small right now (and will be in the foreseeable future) so it is not a problem.

    Thanks for your help. If there are any other problems you foresee in this design please let me know.

    Jon

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

Similar Threads

  1. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  2. Auto Title
    By Lois in forum Forms
    Replies: 1
    Last Post: 10-21-2011, 09:21 AM
  3. Form title dlookup problem
    By zoinnk in forum Forms
    Replies: 3
    Last Post: 10-03-2011, 08:40 AM
  4. No useful title
    By cap.zadi in forum Access
    Replies: 1
    Last Post: 09-05-2011, 09:50 AM
  5. Replies: 6
    Last Post: 02-08-2011, 09:22 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 - Senior Forums