Results 1 to 4 of 4
  1. #1
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276

    Show & Hide Text Box with a Button

    I have a button "VwBtn" the on click property is set as follows:



    Private Sub VwBtn_Click()

    Me.Prctxt.Visible = True

    End Sub


    What code should I add that if I click again on this VwBtn the Prctxt hides.
    e.g once I click the button it shows Prctxt Text Box and If I click on the same button it hides Prctxt Text Box

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    1 button, 1 line o code...

    Code:
    Private Sub VwBtn_Click()
    Me.Prctxt.Visible = not Me.Prctxt.Visible
    End Sub

  3. #3
    aamer is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Jul 2010
    Location
    Pakistan
    Posts
    276
    Thx it worked


    Can you please further assist. there is a problem with the following code. where 128 is the password the highlighted lines are not correct.



    Private Sub Vwtxt_Click()
    Const MESSAGETEXT = "Incorrect password."
    If StrComp(Me.Vwtxt, "128", vbBinaryCompare) = 0 Then
    Me.Prctxt.Visible = Not Me.Prctxt.Visible, OpenArgs:="Protected"
    Me.Label80.Visible = Not Me.Label80.Visible, OpenArgs:="Protected"

    Else
    MsgBox MESSAGETEXT, vbExclamation, "Warning"
    Me.Vwtxt = Null
    Me.Vwtxt.SetFocus
    End If
    End Sub

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    In all my years in Access, I've never heard of a textbox having an openargs property?? I could stand to learn something today if that's the case.

    If you are trying to open a form with that argument, you cannot do it in the same line that you set the textbox's visibility. Also, if that label is attached to the control, you don't have to worry about setting visibility for it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2014, 09:56 PM
  2. Replies: 1
    Last Post: 09-27-2013, 12:49 PM
  3. Hide Show Text Box
    By Derrick T. Davidson in forum Forms
    Replies: 3
    Last Post: 04-09-2013, 11:13 PM
  4. Replies: 3
    Last Post: 11-18-2012, 12:49 PM
  5. Making a toggle button hide a text box.
    By RemonKoybito in forum Forms
    Replies: 3
    Last Post: 05-20-2011, 11:34 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