+ Reply to Thread
Results 1 to 4 of 4

Hide field when txt input

  1. #1
    Registered User
    Join Date
    09-06-2011
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4

    Hide field when txt input

    I am not so good at VBA with excel, so can someone help me please. I have two fields a) Customer number (named as txtCust) and b) Account number (named as txtAccount). I want to write code, if anything entered in customer number field, account number should be disabled and vice versa. So only one field to be allowed to enter at one time.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Hide field when txt input

    Need more information

    Are these on a form?
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    09-06-2011
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4

    Re: Hide field when txt input

    Yes they are on a form as text fields.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983

    Re: Hide field when txt input

    You will need coding for each txt box

    Code disables the other txt box if it has an entry in it & also changes the txtbox colour so that it is not as enticing for a person to select it.
    Another option would be to hide the textbox using the visible setting instead of changing the colour


    A list of colours can be found at http://dmcritchie.mvps.org/excel/colors.htm

    Private Sub txtAccount_change()

    If Me.txtAccount.Value = "" Then
    Me.txtCust.Enabled = True
    Me.txtCust.BackColor = RGB(255, 255, 255)
    Else
    Me.txtCust.Enabled = False
    Me.txtCust.BackColor = RGB(192, 192, 192)
    End If
    End Sub


    Private Sub txtCust_Change()
    If Me.txtCust.Value = "" Then
    Me.txtAccount.Enabled = True
    Me.txtAccount.BackColor = RGB(255, 255, 255)
    Else
    Me.txtAccount.Enabled = False
    Me.txtAccount.BackColor = RGB(192, 192, 192)
    End If
    End Sub
    Last edited by mudraker; 09-07-2011 at 12:51 AM. Reason: adding more info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1