Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Text Box Question

Discussion in 'Information Technology' started by Bob, Jul 28, 2006.

Tags:
  1. Bob

    Bob
    Expand Collapse
    Guest

    I have a text box on my form, can I have it blank until I click the cursor
    in it to reveal its content


    Thanks in advance.........Bob Vance
     
  2. Loading...

    Similar Threads Forum Date
    Malaysia Hindus, Sikhs In Malaysia Appalled With University Textbook Ridiculing Their Faiths Breaking News Jun 14, 2016
    Hard Talk Taking One Liners Out Of Context From Gurbani To Allow Intellectual Independence? Hard Talk Apr 23, 2016
    India Protests in India Over the Desecration of a Holy Text Leave Two Dead Breaking News Oct 16, 2015
    Learn Punjabi Convert Punjabi text Language, Arts & Culture Oct 11, 2013
    Sikh Coalition Harmeet Kaur Took the Lead ! First to Respond to Textbook Challenge ! Sikh Organisations May 25, 2013

  3. Tom Wickerath

    Tom Wickerath
    Expand Collapse
    Guest

    Hi Bob,

    Strange request, but this should get you going...

    Create two textboxes that are identical in size and shape. For the purposes
    of this example, I named one of them txtBookTitle and the other one
    txtHiddenTitle. I'm also using a field that is named BookTitle. Make the
    appropriate substitutions in your case. Set the following attributes:

    txtBookTitle
    Visible: Yes
    Control Source: leave blank (ie unbound)

    txtHiddenTitle
    Visible: No
    Control Source: BookTitle

    txtHidden
    Visible: Yes
    Width: 0
    Height: 0
    Back Color: Use the same value as the detail section
    Special Effect: Flat
    Border Color: Same as detail section
    Fore Color: Same as detail section


    Add the following procedures to the code module for this form:

    Option Compare Database
    Option Explicit

    Private Sub Form_Current()
    On Error GoTo ProcError

    Me.txtHiddenTitle.Visible = Me.NewRecord
    Me.txtBookTitle.Visible = Not (Me.txtHiddenTitle.Visible)
    Me.txtHidden.SetFocus

    ExitProc:
    Exit Sub
    ProcError:
    MsgBox "Error " & Err.Number & ": " & Err.Description, _
    vbCritical, "Error in procedure Form_Current..."
    Resume ExitProc
    End Sub

    Private Sub txtBookTitle_GotFocus()
    On Error GoTo ProcError

    Me.txtBookTitle = Me.txtHiddenTitle

    ExitProc:
    Exit Sub
    ProcError:
    MsgBox "Error " & Err.Number & ": " & Err.Description, _
    vbCritical, "Error in procedure txtBookTitle_GotFocus..."
    Resume ExitProc
    End Sub

    Private Sub txtBookTitle_Exit(Cancel As Integer)
    On Error GoTo ProcError

    Me.txtBookTitle = ""

    ExitProc:
    Exit Sub
    ProcError:
    MsgBox "Error " & Err.Number & ": " & Err.Description, _
    vbCritical, "Error in procedure txtBookTitle_Exit..."
    Resume ExitProc
    End Sub

    If you want to allow the user to edit an existing record, then add the
    following procedure:

    Private Sub txtBookTitle_BeforeUpdate(Cancel As Integer)
    On Error GoTo ProcError

    Me.txtHiddenTitle = Me.txtBookTitle

    ExitProc:
    Exit Sub
    ProcError:
    MsgBox "Error " & Err.Number & ": " & Err.Description, _
    vbCritical, "Error in procedure txtBookTitle_BeforeUpdate..."
    Resume ExitProc
    End Sub


    Finally, position the two textboxes with exactly the same Left and Top
    values, so that they are perfectly overlaying each other. The very small
    txtHidden textbox receives focus (it's visible property must by Yes) when you
    navigate between records. This way, the user is forced to click into the
    txtBookTitle field in order to display the value.


    Tom Wickerath
    Microsoft Access MVP

    http://www.access.qbuilt.com/html/expert_contributors.html
    http://www.access.qbuilt.com/html/search.html
    __________________________________________

    "Bob" wrote:

    > I have a text box on my form, can I have it blank until I click the cursor
    > in it to reveal its content
    >
    >
    > Thanks in advance.........Bob Vance
     
  4. Steve Schapel

    Steve Schapel
    Expand Collapse
    Guest

    Bob,

    As an alternative to Tom's excellent suggestion, you might try
    Conditional Formatting. Select the textbox in design view of the form,
    then select 'Conditional Formatting' from the Format menu. In the
    'Default Formatting' panel, set it so that the text colour is the same
    as the back colour. In the Condition1 box, select 'Field Has Focus',
    and set the text colour as required.

    --
    Steve Schapel, Microsoft Access MVP

    Bob wrote:
    > I have a text box on my form, can I have it blank until I click the cursor
    > in it to reveal its content
    >
    >
    > Thanks in advance.........Bob Vance
    >
    >
     
  5. Tom Wickerath

    Tom Wickerath
    Expand Collapse
    Guest

    Hi Steve,

    That seems like a much easier than the method I suggested! Thanks.

    I'd probably still go with the idea of the small txtHidden textbox, setting
    focus to this control in the Form_Current event procedure, so that it would
    force a person to either tab or click into the textbox that Bob wants to
    leave blank.


    Tom Wickerath
    Microsoft Access MVP

    http://www.access.qbuilt.com/html/expert_contributors.html
    http://www.access.qbuilt.com/html/search.html
    __________________________________________

    "Steve Schapel" wrote:

    > Bob,
    >
    > As an alternative to Tom's excellent suggestion, you might try
    > Conditional Formatting. Select the textbox in design view of the form,
    > then select 'Conditional Formatting' from the Format menu. In the
    > 'Default Formatting' panel, set it so that the text colour is the same
    > as the back colour. In the Condition1 box, select 'Field Has Focus',
    > and set the text colour as required.
    >
    > --
    > Steve Schapel, Microsoft Access MVP
     
  6. Bob

    Bob
    Expand Collapse
    Guest

    Steve I tried you system and I could not get it to work
    still showed the names in the text box...Thanx Bob

    "Steve Schapel" <schapel@mvps.org.ns> wrote in message
    news:u2lPc3xkGHA.3596@TK2MSFTNGP05.phx.gbl...
    > Bob,
    >
    > As an alternative to Tom's excellent suggestion, you might try Conditional
    > Formatting. Select the textbox in design view of the form, then select
    > 'Conditional Formatting' from the Format menu. In the 'Default
    > Formatting' panel, set it so that the text colour is the same as the back
    > colour. In the Condition1 box, select 'Field Has Focus', and set the text
    > colour as required.
    >
    > --
    > Steve Schapel, Microsoft Access MVP
    >
    > Bob wrote:
    >> I have a text box on my form, can I have it blank until I click the
    >> cursor in it to reveal its content
    >>
    >>
    >> Thanks in advance.........Bob Vance
     
  7. Tom Wickerath

    Tom Wickerath
    Expand Collapse
    Guest

    Hi Bob,

    I also tried Steve's suggestion, and it worked fine for me. Did you set the
    Fore Color to match the Back Color for the textbox in question? For example,
    in design view, I set the following properties for the textbox that should
    appear blank:

    Back Color 16777215
    Fore Color 16777215

    This is basically white on white. Then use Conditional Formatting to change
    the font color to black for the condition "Field Has Focus".


    Tom Wickerath
    Microsoft Access MVP

    http://www.access.qbuilt.com/html/expert_contributors.html
    http://www.access.qbuilt.com/html/search.html
    __________________________________________

    "Bob" wrote:

    > Steve I tried you system and I could not get it to work
    > still showed the names in the text box...Thanx Bob
     
  8. Bob

    Bob
    Expand Collapse
    Guest

    Brilliant got it had had round wrong way!!

    "Bob" <xxx@xx.xx> wrote in message news:e74pbh$dkj$1@lust.ihug.co.nz...
    > Steve I tried you system and I could not get it to work
    > still showed the names in the text box...Thanx Bob
    >
    > "Steve Schapel" <schapel@mvps.org.ns> wrote in message
    > news:u2lPc3xkGHA.3596@TK2MSFTNGP05.phx.gbl...
    >> Bob,
    >>
    >> As an alternative to Tom's excellent suggestion, you might try
    >> Conditional Formatting. Select the textbox in design view of the form,
    >> then select 'Conditional Formatting' from the Format menu. In the
    >> 'Default Formatting' panel, set it so that the text colour is the same as
    >> the back colour. In the Condition1 box, select 'Field Has Focus', and
    >> set the text colour as required.
    >>
    >> --
    >> Steve Schapel, Microsoft Access MVP
    >>
    >> Bob wrote:
    >>> I have a text box on my form, can I have it blank until I click the
    >>> cursor in it to reveal its content
    >>>
    >>>
    >>> Thanks in advance.........Bob Vance

    >
    >
     

Share This Page