Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data Validation: Userforms & Combo Boxes (97 SR2)

    I've got several combo boxes on my userforms that use specific row sources. My question is, if an item the user enters is not in the combo box, is there any way to place it in a separate column?

    For example, if the user types in an office that is not in my list, can I pull this and put it into another column?

    Any help would be greatly appreciated!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  2. #2
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Winnipeg, Canada
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data Validation: Userforms & Combo Boxes (97 SR2)

    Hi Drk,

    Not entirely sure what you're asking.

    >>can I pull this

    You can compare new item to combo list and if not found...

    >> and put it into another column?

    if test is true, you can designate the

    Cells(myRow, myCol) = cboBox.Text

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Northern, California, USA
    Posts
    1,886
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data Validation: Userforms & Combo Boxes (97 SR2)

    I'm missing everything but the if not in row source statement...

    Sub combobox_afterupdate() '<=- I assume this is the right syntax...
    'Comparison statement here...
    combobox.value = range("A" & i).value
    end sub

    I represents the current row, and is publicly declared and assigned elsewhere in the code.

    Any help would be greatly appreciated!
    <IMG SRC=http://www.wopr.com/w3tuserpics/Kel_sig.gif>
    Moderator:<font color=448800> Pix Place, Internet Explorer</font color=448800>
    <small>www.kvisions.com

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Winnipeg, Canada
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data Validation: Userforms & Combo Boxes (97 SR2)

    Hi Drk,

    Sorry, I must be a bit confused, but I think you want
    to compare the typed value in the Combobox to the
    combobox list?

    Try this code:

    Private Function AlreadyListed(ListControl As Control, NewItem As String) As Boolean
    Dim i As Integer

    AlreadyListed = False

    For i = 0 To ListControl.ListCount - 1
    If UCase$(ListControl.List(i)) = UCase$(NewItem) Then AlreadyListed = True
    Next i
    End Function

    Private Sub cboOffice_AfterUpdate()
    If Not AlreadyListed(cboOffice, cboOffice.Text) Then
    'Do something here
    MsgBox "Not in the list"
    End If
    End Sub

Posting Permissions

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