Results 1 to 4 of 4
  1. #1
    brobertson89 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    19

    Making text visible based on combo boxes when you change records

    I have used the following code to make visible or make unvisible certain labels and text boxes based on the selection from a combo box. The problem is when I go to the next record the labels and text boxes showing are those that were selected to be visible based on the choice made on the previous records combo box. For example if on the first record cboInserts is selected as 2 then Insert_Type2, Insert_Serial2, InsertLabel2 and InsertLabel5 are set as visible. When I go to the next record cboInserts is selected as 1 so these should not be visible but they are now. Any help would be greatly appreciated. Thank you in advance!

    Private Sub cboInserts_AfterUpdate()
    If Me.cboInserts.Value >= 1 Then
    Me.Insert_Type1.Visible = True
    Me.Insert_Serial1.Visible = True
    Me.InsertLabel1.Visible = True
    Me.InsertLabel4.Visible = True
    Else
    Me.Insert_Type1.Visible = False
    Me.Insert_Serial1.Visible = False
    Me.InsertLabel1.Visible = False
    Me.InsertLabel4.Visible = False
    End If
    If Me.cboInserts.Value >= 2 Then
    Me.Insert_Type2.Visible = True
    Me.Insert_Serial2.Visible = True
    Me.InsertLabel2.Visible = True
    Me.InsertLabel5.Visible = True
    Else
    Me.Insert_Type2.Visible = False
    Me.Insert_Serial2.Visible = False
    Me.InsertLabel2.Visible = False


    Me.InsertLabel5.Visible = False
    End If
    If Me.cboInserts.Value >= 3 Then
    Me.Insert_Type3.Visible = True
    Me.Insert_Serial3.Visible = True
    Me.InsertLabel3.Visible = True
    Me.InsertLabel6.Visible = True
    Else
    Me.Insert_Type3.Visible = False
    Me.Insert_Serial3.Visible = False
    Me.InsertLabel3.Visible = False
    Me.InsertLabel6.Visible = False
    End If
    End Sub

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    In the OnCurrent event of the form; put in this same type code specifically setting all the field parameters back to their starting point.

  3. #3
    brobertson89 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    19
    That is awesome, just what I needed. Thank you!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Consider alternative code:

    Me.Insert_Type1.Visible = Me.cboInserts.Value >= 1
    Me.Insert_Serial1.Visible = Me.cboInserts.Value >= 1
    Me.InsertLabel1.Visible = Me.cboInserts.Value >= 1
    Me.InsertLabel4.Visible = Me.cboInserts.Value >= 1

    Me.Insert_Type2.Visible = Me.cboInserts.Value >= 2
    Me.Insert_Serial2.Visible = Me.cboInserts.Value >= 2
    Me.InsertLabel2.Visible = Me.cboInserts.Value >= 2
    Me.InsertLabel5.Visible = Me.cboInserts.Value >= 2

    Me.Insert_Type3.Visible = Me.cboInserts.Value >= 3
    Me.Insert_Serial3.Visible = Me.cboInserts.Value >=3
    Me.InsertLabel3.Visible = Me.cboInserts.Value >= 3
    Me.InsertLabel6.Visible = Me.cboInserts.Value >= 3
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-07-2014, 08:48 AM
  2. Replies: 30
    Last Post: 07-21-2014, 02:46 PM
  3. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  4. Visible text boxes when combo box choice selected
    By nichmeg in forum Programming
    Replies: 3
    Last Post: 10-16-2011, 02:53 PM
  5. Replies: 18
    Last Post: 04-08-2011, 09:20 PM

Tags for this Thread

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