Consulting

Results 1 to 2 of 2

Thread: Combobox question

  1. #1
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    362
    Location

    Combobox question

    Hi all,

    I've got a userform with a combobox that I set the list items via VBA.

    question is:
    how do I make the validation list disappear after the code has finished?
    I currently have to click the list once to make it go away, and then reopen the list and set the combobox value
    tis kinda annoying.

    the relevant code is the section following 'myarray = getfittingtype(myString)'

    Thanks

    Private Sub cbxLampType_AfterUpdate()
    'create lookup values for fitting type and balast type
    Dim myCbox As ComboBox
    Dim myArray() As String
    Dim myRow As Long
    Dim myString As String
    Dim myFlag As Boolean
    
    
    If enableFormEvents = False Then Exit Sub
    
    
    myString = frmAssessment.cbxLampType.Value
    Set myCbox = frmAssessment.cbxFittingType
    myFlag = False
        
        If myString = "" Then Exit Sub 'quit if no lamp type is selected
        
        myArray = GetFittingType(myString)
        myCbox.Clear
        For myRow = 1 To UBound(myArray)    'set fitting type validation
            myCbox.AddItem myArray(myRow)
            If myCbox.Value = myArray(myRow) Then myFlag = True
        Next myRow
        If myFlag = False Then myCbox.Value = ""
        
        Erase myArray()
        Set myCbox = frmAssessment.cbxControlGear
        myFlag = False
        
        myArray = GetControlGear(myString)
        For myRow = 1 To UBound(myArray)    'set control gear validation
            myCbox.AddItem myArray(myRow)
            If myCbox.Value = myArray(myRow) Then
                myFlag = True   'a valid value exists
            End If
        Next myRow
        If myFlag = False Then myCbox.Value = GetDefaultBalast(myString)
    
    
    End Sub
    Remember: it is the second mouse that gets the cheese.....

  2. #2
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    362
    Location
    Dang,
    the blasted thing just started behaving - and I didn't do anything
    Remember: it is the second mouse that gets the cheese.....

Posting Permissions

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