Solved

Data Connection From Excel 2007 to Access 2007 Query With Selection Criteria

Posted on 2011-09-02
3
209 Views
Last Modified: 2012-05-12
Hi,
I want to build a data connection between from Excel 2007 to Access 2007 to an Access query that has one selection criteria using vba code.

I would appreciate any help!

Thanks
Gary
0
Comment
Question by:tgtg7
  • 2
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 36475252
you can use codes like this

dim db as dao.database, sql as string, rs as dao.recordset, dbPath as string
dbPath="< complete path to the db >"

    set db=opendatabase(dbPath)
   
    sql="select * from table where <criteria string >"

    set rs=db.openrecordset(sql)

   
what are you trying to do ?
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36475457
..to continue, you can then display the result with

     worksheets("sheet1").range("a1").copyfromrecordset rs
0
 

Author Closing Comment

by:tgtg7
ID: 36510484
thanks!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now