Results 1 to 4 of 4
  1. #1
    LukeJ Innov is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    31

    Search Box that auto-populates

    Hello All,

    I am trying to create a search box on a form so that when something is searched and selected it auto populates textboxes on the form.
    For instance:
    I have a table called contacts, it houses data on contact name, work department, phone numbers etc. I have a form that allows the user to view the contact data, but how would I implement a search control so the user can search for something and it pulls the data from the table and plugs it in to the form fields.
    I have tried using a combo box, but all I can get it to do is simply display values.

    Thanks in advance,



    Regards
    LJ

  2. #2
    pradeep.sands is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    49
    Hi,
    Like you said you have contactname, wrkdept, phnum fields. And you have 3 text boxes (names txtbox1,txtbox2,txtbox3) to display these three field values.
    Like you said, when you search for something, is your result stored as a query or recordset? If so, then you can simply write this code:
    txtbox1 = Me.Fields(1).Value
    txtbox2 = Me.Fields(2).Value
    txtbox3 = Me.Fields(3).Value

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's a step-by-step for using a Combobox to retrieve an existing Record:

    Create a Form based on your Table, including all the Fields you want displayed.

    Then simply:

    • Add a Combobox to your Form.
    • The Combobox Wizard will pop up
    • Select "Find a record based on the value I selected in my combobox."
    • From the Table the Form is based on, click on the Field you're searching by (a Field that is unique for each Record) to move it to the right side.
    • Hit Next.
    • Size the column appropriately.
    • Hit Next.
    • Name the Combobox something appropriate.
    • Hit Finish.

    Now you can drop the Combobox down and scroll down to the item to search by, or you can start to enter the item and the Combobox will "autofill" as you type. Hit <Enter> and the Record will be retrieved.

    Linq ;0)>

  4. #4
    LukeJ Innov is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    31
    Many many thanks Missinglinq.

    I think the problem was that my form was not created based on a table, I had a blank form in which I had dragged fields onto it, and the option in the wizard was not their.
    Regards
    LJ

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

Similar Threads

  1. Replies: 3
    Last Post: 06-12-2013, 06:44 PM
  2. Replies: 1
    Last Post: 05-27-2013, 09:46 PM
  3. Replies: 3
    Last Post: 11-09-2011, 03:43 PM
  4. Combo Box Populates Textboxes
    By alyon in forum Access
    Replies: 11
    Last Post: 07-19-2011, 11:55 AM
  5. Replies: 3
    Last Post: 09-26-2009, 01:57 PM

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