+ Reply to Thread
Results 1 to 5 of 5

From Excel, search Access database and return all matches to a variable value

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Bemidji, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    15

    From Excel, search Access database and return all matches to a variable value

    Hello. This question relates to using Excel as a front end user interface to view data stored in an Access database. Let's say that I have a database in Access that lists different types of fruit (field 1) and their color (field 2). I would like the Excel user to be able to type a color in an Excel worksheet field A2, let's say "red". Excel would then list all the red fruits in Column C, either via formulas housed in Column C fields or via VBA. I know I could do this by creating a linked table in another Excel worksheet that would display all the Access data and then using a formula such as VLOOKUP to return all the matches, but I'm wondering if it is possible to do this more simply and straightforward without having to first import the entire linked data table into Excel. Whatever solution is suggested needs to work across different versions of Excel (2007-2016) and should be able to look through several thousand records very quickly to find matches. Thanks in advance for the help!
    Last edited by bemidjipatriot; 04-23-2017 at 10:10 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: From Excel, search Access database and return all matches to a variable value

    This is more a pointer than a solution.

    Do you know how to write and run SQL queries? If you do, you can simply run a statement in excel as if you are working in Access. I do not know much about Access's Stored procedures, but I know this can be done in SQL Server. The Stored procedure is written and stored in database, but this function can be called from Excel. What is more, you can easily refresh and update excel whenever the database has been updated.
    Last edited by AB33; 04-23-2017 at 10:26 AM.

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: From Excel, search Access database and return all matches to a variable value

    Something like this. Change sCnn to the filepath of you db. Also depending on what Access data base you are using change for your needs. .2003 Access Use Jet
    2007 db or higher use ACE

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Registered User
    Join Date
    11-27-2012
    Location
    Bemidji, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: From Excel, search Access database and return all matches to a variable value

    Thanks, AB33. I don't know anything about this, being a new Access user. Could someone point me towards some tutorials or instructions that would explain how to do this?

    (Also, thanks Mike for the code to try in Excel. Much appreciated!)

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: From Excel, search Access database and return all matches to a variable value

    Mike has provided you with code base.


    You can understand most of the lines of code
    sSQL = "SELECT Table1.Fruit FROM Table1 WHERE (((Table1.Color)='" & Cells(2, 1).Value & "'));"
    is a SQL(Structured Query Language) statement which is like a Vlookup function.
    SQL is not difficult to learn. You only need few commands to do lots of work in Database.
    W3 site has good resources in SQL.

+ 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. Search a table with multiple search inputs and return all matches
    By JDI in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-16-2014, 12:23 PM
  2. Query Access database and return all records to Excel
    By bfs3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2014, 11:01 PM
  3. Replies: 2
    Last Post: 07-05-2013, 09:37 AM
  4. Using ADO in Excel VBA - Search for Field in Access Database
    By JStoops in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2010, 04:46 PM
  5. Using ADO in Excel VBA-Search for Field in Access Database
    By JStoops in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2010, 04:11 AM
  6. Import to excel Access database directly to a variable (not using sheets)
    By internacio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2006, 10:10 AM
  7. Excel function to search and access database problem
    By Brian K. Sheperd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2005, 04:06 PM

Tags for this Thread

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