Display for Text Box (Access 2003)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • truthlover
    New Member
    • Dec 2007
    • 107

    Display for Text Box (Access 2003)

    Is there a way to have text display in a data entry form that will not be stored as an actual value (like a default value does)?

    Status bar and Tool tips wont work. I need something that will display in an empty data entry field.

    Thanks!
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Hi
    You can use the On_Open or On_Current event of a form to automatically place text in a Textbox
    Code:
     Me!MyTextBox = "My Text ?"
    However, if you have a Bound Form and Me!MyTextBox is bound to field [MyText] (i.e. ControlSource = [MyText]) then this will be written to the database.

    If the Control Source is blank, you have an Un-Bound control, so the data will be displayed but not saved anywhere, so is not a data entry box.
    You could have another event read this data and then copy it to a bound contril (that could be hidden) but what are you trying to do?

    S7

    Comment

    • truthlover
      New Member
      • Dec 2007
      • 107

      #3
      The fields are all bound controls.

      What I'm trying to do is make the data entry as simple to use as possible. So I would like to have tool tips in the form of text inside the empty text field (since they'll never look at the status bar and the mouse-over tips are too easy to ignore).

      I have one popup message, but even that one gets really annoying after a while and there is no room on the form to put the tips near the control

      Thanks

      Originally posted by sierra7
      Hi
      You can use the On_Open or On_Current event of a form to automatically place text in a Textbox
      Code:
       Me!MyTextBox = "My Text ?"
      However, if you have a Bound Form and Me!MyTextBox is bound to field [MyText] (i.e. ControlSource = [MyText]) then this will be written to the database.

      If the Control Source is blank, you have an Un-Bound control, so the data will be displayed but not saved anywhere, so is not a data entry box.
      You could have another event read this data and then copy it to a bound contril (that could be hidden) but what are you trying to do?

      S7

      Comment

      • sierra7
        Recognized Expert Contributor
        • Sep 2007
        • 446

        #4
        Hi

        I think what you mean is you want 'Type Your Name Here' inside the text box label 'Name' ??? or similar

        (I'm not going to forgive myself for this!) I've got something like this working by making the TextBox Background Style = Transparent and placing a Label behind it with the required text. The label must be exactly the same size as your TextBox. The After_Update event on the text box is;
        [CODE=vb] Private Sub Text13_AfterUpd ate()
        If Me.Text13 <> "" Then
        Me.Text13.BackS tyle = 1
        Else
        Me.Text13.BackS tyle = 0
        End If
        End Sub
        [/CODE] so the label is visible until there is data in the text box, then the BackStyle is changed to Normal (1) to hide the label.

        You would have to do this for every field on your form, then you would have to copy and paste all of these bits of code into a new Sub, lets call it DisplayHelp, which you would need to call in the On_Current event of the Form, so that it would reset for each record. I suppose you could have the Label backcolour different to the TextBox then it would highlight what was Data and what was Help text. Different Fonts might help too (It sound like this is growing on me!)

        If you really liked the effect you could probably wrap it up in a Public module.
        [CODE=]
        Sub DisplayHelp(Fna me As Form)
        Dim frm As Form
        Dim ctl As Control

        Set frm = Fname

        For Each ctl In frm.Section(acD etail).Controls
        With ctl
        Select Case .ControlType
        Case acComboBox
        If .Value <> "" Then
        .BackStyle =1
        Else
        .BackStyle =0
        EndIf


        Case acTextBox
        If .Value <> "" Then
        .BackStyle =1
        Else
        .BackStyle =0
        EndIf
        End Select
        End With
        Next ctl

        End Sub

        [/CODE]

        You would call it by putting
        Code:
        DisplayHelp Me
        in all the after_updates and On_Currents where needed

        I HAVE NOT TESTED this and it may need polishing a bit but should give you the idea.

        Best of luck

        S7

        Comment

        • truthlover
          New Member
          • Dec 2007
          • 107

          #5
          Originally posted by sierra7
          I think what you mean is you want 'Type Your Name Here' inside the text box label 'Name' ??? or similar
          Yes, that's exactly what I want.

          That's an interesting solution. I'll give it a try, thanks!

          Originally posted by sierra7
          (I'm not going to forgive myself for this!) I've got something like this working by making the TextBox Background Style = Transparent and placing a Label behind it with the required text. The label must be exactly the same size as your TextBox. The After_Update event on the text box is;
          [CODE=vb] Private Sub Text13_AfterUpd ate()
          If Me.Text13 <> "" Then
          Me.Text13.BackS tyle = 1
          Else
          Me.Text13.BackS tyle = 0
          End If
          End Sub
          [/CODE] so the label is visible until there is data in the text box, then the BackStyle is changed to Normal (1) to hide the label.

          You would have to do this for every field on your form, then you would have to copy and paste all of these bits of code into a new Sub, lets call it DisplayHelp, which you would need to call in the On_Current event of the Form, so that it would reset for each record. I suppose you could have the Label backcolour different to the TextBox then it would highlight what was Data and what was Help text. Different Fonts might help too (It sound like this is growing on me!)

          If you really liked the effect you could probably wrap it up in a Public module.
          [CODE=]
          Sub DisplayHelp(Fna me As Form)
          Dim frm As Form
          Dim ctl As Control

          Set frm = Fname

          For Each ctl In frm.Section(acD etail).Controls
          With ctl
          Select Case .ControlType
          Case acComboBox
          If .Value <> "" Then
          .BackStyle =1
          Else
          .BackStyle =0
          EndIf


          Case acTextBox
          If .Value <> "" Then
          .BackStyle =1
          Else
          .BackStyle =0
          EndIf
          End Select
          End With
          Next ctl

          End Sub

          [/CODE]

          You would call it by putting
          Code:
          DisplayHelp Me
          in all the after_updates and On_Currents where needed

          I HAVE NOT TESTED this and it may need polishing a bit but should give you the idea.

          Best of luck

          S7

          Comment

          Working...