Results 1 to 3 of 3
  1. #1
    Rramjet is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    36

    Changing field visibility based on value in another field

    Hi all -

    I am very new to Access so please forgive me if I am making some basic mistakes...

    I want to make one field invisible based on the value of another field. Looking in these forums I found the following code (modified to my own field names & values):

    Private Sub Form_Current()
    If XYZ_1 = "T3"
    Then


    XYZ_36.Visible = False
    Else
    XYZ_36.Visible = True
    End If
    End Sub

    Private Sub XYZ_Form_Change()
    If XYZ_1 = "T3"
    Then
    XYZ_36.Visible = False
    Else
    XYZ_36.Visible = True
    End If
    End Sub

    Which works fine except for one minor detail - it only works if one uses the mouse to select from the combo box list (attached to XYZ_1). If a user ignores the combo and physically types the value (T3) in, then the visibility of XYZ_36 does not change (and vice versa - if T3 is already selected and XYZ_36 is invisible accordingly - typing another value does not make it reappear).

    Any help appreciated,
    Thanks,
    Rramjet.

  2. #2
    Rramjet is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2013
    Posts
    36
    Okay - Problem solved...


    Had to add the code into:

    Private Sub XYZ_Form_LostFocus()
    If XYZ_1 = "T3"
    Then
    XYZ_36.Visible = False
    Else
    XYZ_36.Visible = True
    End If
    End Sub

    ...making that three bits of the same code all to do one simple thing LOL.

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'd use the after update event of the combo and the current event. The change event fires with each keystroke, the focus event when you don't necessarily care.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Field visibility based on ComboBox selection
    By cactuspete13 in forum Forms
    Replies: 3
    Last Post: 01-30-2013, 03:37 PM
  2. Field Visibility In Combo Box
    By Gabriel2012 in forum Forms
    Replies: 2
    Last Post: 01-24-2013, 07:46 AM
  3. Field visibility in a report
    By PhilTFC in forum Forms
    Replies: 8
    Last Post: 10-29-2012, 12:10 PM
  4. Field Visibility
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 06-27-2012, 03:52 PM
  5. Changing tables based on field date
    By dssrun in forum Programming
    Replies: 6
    Last Post: 07-10-2011, 10:17 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