+ Reply to Thread
Results 1 to 5 of 5

Use textbox in userform to retrieve data

  1. #1
    Registered User
    Join Date
    07-29-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Use textbox in userform to retrieve data

    G'day Excel gurus,

    I currently have a Userform I use to retrieve data from a worksheet. I am currenlty using a combo box to enter the search criteria of an employee ID number. As you know, it is a dropdown type box, and will list ALL employee IDs listed on the source worksheet.

    When my database gets fully updated, I will have over one hundred employee IDs which means my combo box will list over 100 numbers to choose from.

    What I would like to know is... can a 'textbox' be used (ie: manually type a known employee ID), using a VLOOKUP or .find function? I would also like a msgbox to pop up if the empl ID is not found.

    Any help is muchly appreciated.

    Fogsta
    Last edited by Fogsta65; 08-11-2013 at 11:08 PM.

  2. #2
    Registered User
    Join Date
    11-14-2010
    Location
    Macau
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Use textbox in userform to retrieve data

    Hi,
    Please see the below code as some ideas may help you..

    Please Login or Register  to view this content.
    First you create the textbox for ask user input some id information to search criteria rapidly.
    (so above code is textbox change represent for new textbox)
    second is create the listbox to display the information to choose as per criteria.
    (so above code is listbox1 represent for listing id or some data to choose (click) )

  3. #3
    Registered User
    Join Date
    07-29-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Use textbox in userform to retrieve data

    Lutoxel,

    Thanks for your response. That code caused a problem with opening the search userform for some reason.

    I already have the code that drags the info I want from a spreedsheet to the userform (using a combo box). I just need to know if a textbox can be used for the search instead of a combo or list box. As soon as I get rid of my combo box and change it to a textbox, the 'search' macro to bring up the userform fails.

    It would be preferable if, in the search userform, I could type in the Employee ID, click a retrieve cmdbutton and vua la.... Up comes the info. Using the dropdown and scrolling through a hundred employee IDs is a pain.

    John

  4. #4
    Registered User
    Join Date
    11-14-2010
    Location
    Macau
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Use textbox in userform to retrieve data

    As according to your query, textbox can use for search, but you have put it with for searching purpose only.
    If you submit sample file may more clear to advice.

  5. #5
    Registered User
    Join Date
    07-29-2013
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Use textbox in userform to retrieve data

    G'day Lotuxel,

    I've attempted in the past to attach the database, but it is too big to upload. Here is the code I use to retrieve data, indicating the combo box (cmbEmplID) as the search cell:


    Private Sub UserForm_Initialize()
    Dim rng As Range

    With Sheets(2)
    Set rng = .Range("A3", .Range("A" & Rows.Count).End(xlUp))
    End With

    cmbEmplID.List = rng.Value

    End Sub


    Private Sub CommandButtonGetData_Click()
    Dim idx As Long

    idx = cmbEmplID.ListIndex

    If idx <> -1 Then
    With Worksheets("Recall")
    Rank_Title.Value = .Cells(idx + 3, 2).Value
    Surname.Value = .Cells(idx + 3, 3).Value
    FirstName.Value = .Cells(idx + 3, 4).Value
    Address.Value = .Cells(idx + 3, 5).Value
    Suburb.Value = .Cells(idx + 3, 6).Value
    State.Value = .Cells(idx + 3, 7).Value
    Postcode.Value = .Cells(idx + 3, 8).Value
    HomeNo.Value = .Cells(idx + 3, 9).Value
    MobileNo.Value = .Cells(idx + 3, 10).Value
    WorkNo.Value = .Cells(idx + 3, 11).Value
    DOB.Value = .Cells(idx + 3, 12).Value
    DefEmail.Value = .Cells(idx + 3, 13).Value
    Dept.Value = .Cells(idx + 3, 14).Value
    PECTitle = .Cells(idx + 3, 15).Value
    PECSurname = .Cells(idx + 3, 16).Value
    PECFirstNames = .Cells(idx + 3, 17).Value
    PECRelationship = .Cells(idx + 3, 18).Value
    PECReligion = .Cells(idx + 3, 19).Value
    PECAddress = .Cells(idx + 3, 20).Value
    PECSuburb = .Cells(idx + 3, 21).Value
    PECState = .Cells(idx + 3, 22).Value
    PECPostcode = .Cells(idx + 3, 23).Value
    PECPrimaryNo = .Cells(idx + 3, 24).Value
    PECAltNo = .Cells(idx + 3, 25).Value
    PECEmail = .Cells(idx + 3, 26).Value
    PECAdditional = .Cells(idx + 3, 27).Value

    End With
    End If

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 01-29-2014, 05:53 AM
  2. Automatically Retrieve Data From a worksheet to userform
    By DKTRL in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 02:25 PM
  3. Excel : Input and Retrieve Data using Textbox
    By rajaman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2013, 07:21 AM
  4. Hi. anyone can help me to link this? userform and retrieve data problem
    By yuki0219 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 11:36 AM
  5. Would like to retrieve data from spreadsheet to userform
    By Bucko in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2006, 09:15 AM

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