Results 1 to 3 of 3
  1. #1
    beanie is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2015
    Posts
    3

    Post How to create a Combo box to search for a record

    Hi Forum users,

    I wanted to create a combo box that allows me to search for posts in a certain table. I followed a great tutorial of below:

    http://ms-access-tips.blogspot.jp/20...or-record.html

    I tried is and it worked really good. However, there is one thing that I would be very happy if you could help me to understand.


    My table contains USER_ID, LastName and FirstName.


    The column order that now shows in the combo box is "USER_ID/LastName/FirstName"


    In my case, I would like to have the following order to show in the combo list "LastName/FirstName/USER_ID"
    The "LastName" should also appear in alphabetical order.


    How can I achieve this?

    Do I need to make changes in the VBA-code as of below?

    On Error GoTo myError
    Dim rst As DAO.Recordset
    Set rst = Me.RecordsetClone
    rst.FindFirst "USER_ID = " & Me!ctlSearch
    Me.Bookmark = rst.Bookmark
    leave:
    Me!ctlSearch = Null


    If Not rst Is Nothing Then Set rst = Nothing
    Exit Sub
    myError:
    MsgBox "Record Not Found"
    Resume leave

    or do I have to make changes in the property of the combo box? or a combination of both changing the VBA-code and the properties?

    If anyone could help me to achieve this, I would be very very happy.

    Best Regards,
    Beanie

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Why not use a query and change the order of the fields and specify the sort?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Here is another search article. This one by Allen Browne. It has code and description.
    A good reference.
    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 02-02-2015, 02:14 PM
  2. using combo box to search and got record
    By holysepulchre in forum Forms
    Replies: 10
    Last Post: 01-25-2013, 01:39 PM
  3. Replies: 2
    Last Post: 08-17-2012, 09:28 AM
  4. Search for Record, create new if not existant
    By asmith in forum Programming
    Replies: 3
    Last Post: 09-28-2010, 11:31 AM
  5. Create combo search form in subform
    By grant.smalley in forum Forms
    Replies: 6
    Last Post: 02-19-2010, 04:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums