Results 1 to 6 of 6

Populating text boxes from a combo box choice

Threaded View

  1. #3
    Registered User
    Join Date
    07-23-2012
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2011 for MAC
    Posts
    2

    Re: Populating text boxes from a combo box choice

    Hi Adam,

    Put this code on your user form where the combo box is,
    Private Sub userform_initialize()
    Me.ComboBox1.List = Sheets("Clients").Range("__:__").Value
    End Sub
    I don't know the range of all the 'customer numbers' you have but just plug it in for example ("A6:A1000") thats the range of values that will show up on your combo box list!

    So for your other problem, how to populate the text boxes when people search that customer number.
    You basically have to

    Private Sub cmbSearch_Click()
    
    'For showing data on the form from the spreadsheet
    
    n = LCase(Me.ComboBox1.Value)
    y = Len(n)
    x = 6
    
    If n = "" Then
    MsgBox ("Please choose Customer Number.")
    GoTo J
    End If
    
        Do Until Left(n, y) = LCase(Left(Sheets("Clients").Cells(x, 2), y))
        x = x + 1
        If x = 1000 Then GoTo E
        Loop
    
    Load "INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'
    
    
    Me.Textbox1.Value = Sheets("Clients").Cells(x, 2)
    Me.TextBox2.Value = Sheets("Clients").Cells(x, 3)
    Me.TextBox3.Value = Sheets("Clients").Cells(x, 4)
    Me.TextBox4.Value = Sheets("Clients").Cells(x, 5)
    Me.TextBox5.Value = Sheets("Clients").Cells(x, 6)
    Me.TextBox7.Value = Sheets("Clients").Cells(x, 7)
    
    Unload Me
    "INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'" then add the .Show function
    
    
    GoTo F
    
    E:
    Unload INSERT HERE THE USERFORM WHERE THE TEXTBOXES ARE'
    MsgBox ("This customer number does not exist in the database.")
    
    F:
    Unload Me
    
    
    J:
    
    
    End Sub
    Last edited by arlu1201; 07-28-2012 at 01:01 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1