View Single Post
 
Old 05-12-2019, 07:53 AM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

For your first point, try changing the CompanyName MatchRequired to False and using CompanyName_BeforeUpdate to check for match.
Code:
Private Sub CompanyName_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    Dim myString As String
    Dim i As Long
    Dim strFound As Boolean

'check if combobox value exists in .list
myString = Me.CompanyName.Text
strFound = False
With Me.CompanyName
     'Loop through combobox list
    For i = 0 To .ListCount - 1
        If .List(i) = myString Then
            strFound = True
            Exit For
        End If
    Next i
End With
    
If Not strFound Then
    'entry does not exist
    If Len(myString) > 0 Then
        MsgBox "The entered value is not in the list"
        Cancel = True   'keeps you in the combo
        Me.CompanyName = ""
        Exit Sub
    Else
        'clear the call history
        Me.CallHistory.Clear
        Exit Sub
    End If
Else
    'entry exists
    Call CompanyName_Click
End If

End Sub
Reply With Quote