+ Reply to Thread
Results 1 to 6 of 6

Vlookup inside Access

Hybrid View

djblois1 Vlookup inside Access 03-30-2011, 12:11 PM
alansidman Re: Vlookup inside Access 04-03-2011, 08:28 PM
djblois1 Re: Vlookup inside Access 04-04-2011, 08:38 AM
royUK Re: Vlookup inside Access 04-04-2011, 01:14 PM
djblois1 Re: Vlookup inside Access 04-04-2011, 01:29 PM
barneja Re: Vlookup inside Access 03-08-2012, 01:33 PM
  1. #1
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Vlookup inside Access

    how do I do something similar to look up values in Access?

    right now I use queries in Excel to pull large tables into separate sheets in Excel and then I use vlookups to query these sheets. I want to get rid of that middle step if possible. Can I query the access database with a function or through VBA code?

    Ex:

    Say I have code 556752 and I want to look up the description from a table in Access, how do I do that?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Vlookup inside Access

    Are you looking to do your queries in Access or do you want to run your queries from Excel? Not sure from your question which you wish to do. In Access, you can do a simple select query and put 556752 as your paramter selection in your QBE and make sure to join your two tables.

    If you wish to do it directly in Excel, use MS query and do the same thing as if you were running a query in Access.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Vlookup inside Access

    I am trying to do this in Excel. If I have a list of Product Numbers in one column, I want to use sometime of Function like dlookup to pull the product descriptions from access or another database. How would I do this? I do not want to put the product number in the parameter field because that will not be dynamic. I want to pull it directly from the excel spreadsheet.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Vlookup inside Access

    I can't really decide whether you want an Access solution or Excel solution. You can't use VLOOKUP from Excel to get data from Access
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Contributor
    Join Date
    08-23-2010
    Location
    Staten Island, NY
    MS-Off Ver
    Excel 2003
    Posts
    242

    Re: Vlookup inside Access

    I want an excel solution to pull data from Access. I know you cannot use a V-lookup to pull data from Access but I was wondering if something equivalent can be done to pull data from Access.

  6. #6
    Registered User
    Join Date
    03-08-2012
    Location
    South Jordan, Utah, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Vlookup inside Access

    Hi --

    Did you get an answer yet? If you are looking to stay within Excel then your best bet is to use VBA to create a connection to the database and then create a loop in your Excel VBA to run down your rows one at a time. Something similar to the following . . .

    'Create your connection to your Access db - depending on if you are Access 2007 or 2003 different connection strings - if you don't know the connection string reply and I'll give you two samples . . . I just don't want to get too long winded if you have already received an answer. You'll have to make sure your references are set to handle ADODB sets.

    Assuming the value you are looking up (ie, 556752 from your question) is in column A and you want to put the value you are looking up in column B next to your value you looked up in column A then see the following code. the code is very rudimentary, but it might give you an idea . . .


    Sub HereGoes()

    dim jRecordset as ADODB.Recordset
    dim jSQL as string
    dim i as integer
    dim EndRow as integer


    Range("A1").select
    i=0
    EndRow=selection.end(xldown).row
    for i=1 to EndRow
    jSQL="Select FieldLookingFor FROM tblLookingFrom WHERE FieldMyLookup = " & activecell.offset(i,0) & ";"
    set jRecordset= new adodb.recordset
    jRecordset.Open 'plus your paramaters - if you don't have then I can forward - once again, not sure if you already have answer so . . .
    if not jrecordset.eof then activecell.offset(i,1)=jrecordset!FieldLookingFor
    end if
    j
    recordset.close
    next i
    set jrecordset = nothing

    End Sub

    Let me know if you need more or if this is going in the right direction. I assume from your question that your intent is to stay within Excel to get your lookup accomplished. You do have other options like a DLookup - but I like simple select queries for something like you mentioned.


    Thanks -

    Jim

+ Reply to Thread

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