Results 1 to 2 of 2
  1. #1
    Lxmanager is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    24

    Help with Combo Boxes

    Hi, please could someone tell me what is wrong here?

    I will try my best to explain...

    I have a form with 2 combo boxes and a few text boxes. The operator selects values from the combo boxes which in turn automatically populate the text boxes.. this all works.

    What I want to do when the operator selects a certain value in cboProgClass, a value in cboCylType is automatically selected, dissables that combo box and hides one of the txt boxes. There are 10 different values in cboProgClass but only 4 of them are effected this way.

    The problem is, all four values in cboProgClass change the values in cboCylType as I want but only only last of the four dissables the combo box and hides the text box, plus when the fourth one hides the text box and dissables the combo, changing the values to something other than these four does not bring them back again.. The code is below, unfortunately I am not a VBA programmer.

    Private Sub cboProgClass_AfterUpdate()

    If cboProgClass = "J" Then
    Me.cboCylType.Value = "CLP"
    Me.txtCust1.Visible = False
    Me.cboCylType.Enabled = False
    Else
    Me.txtCust1.Visible = True
    Me.cboCylType.Enabled = True
    End If

    If cboProgClass = "K" Then
    Me.cboCylType.Value = "DCLP"
    Me.cboCylType.Enabled = False
    Me.txtCust1.Visible = False
    Else
    Me.txtCust1.Visible = True
    Me.cboCylType.Enabled = True
    End If
    If cboProgClass = "M" Then
    Me.cboCylType.Value = "LFT"
    Me.cboCylType.Enabled = False
    Me.txtCust1.Visible = False
    Me.cboCylType.Enabled = True
    Else
    Me.txtCust1.Visible = True
    Me.cboCylType.Enabled = True
    End If
    If cboProgClass = "N" Then
    Me.cboCylType.Value = "LWR"
    Me.cboCylType.Enabled = False
    Me.txtCust1.Visible = False
    Else
    Me.txtCust1.Visible = True
    Me.cboCylType.Enabled = True
    End If

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I suspect the problem is the logic of your code. Each If/Then test will be run regardless of previous results, so basically the last test will determine your result. You either want to use ElseIf, or Select/Case, either of which will drop out of the code as soon as one of the tests is met.
    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. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Combo Boxes on a From
    By donnan33 in forum Access
    Replies: 14
    Last Post: 01-17-2012, 08:19 AM
  3. combo boxes
    By donnan33 in forum Programming
    Replies: 9
    Last Post: 12-22-2011, 01:10 PM
  4. Combo Boxes - Many-to-Many
    By alpinegroove in forum Forms
    Replies: 3
    Last Post: 12-19-2011, 06:38 PM
  5. combo boxes
    By googenfrog in forum Forms
    Replies: 3
    Last Post: 07-03-2009, 05:41 PM

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