Linking Excel to Access

Justin01

New Member
Joined
Feb 10, 2003
Messages
2
I have no idea on how to link the two applications together. I want to write a program in which the user opens Excel and asks certain questions on a specific subject.
My information will be contained in tables in access. Now how would i go about grabbing the required info from Access and depositing it in excel.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
We'll you can create a report. When the report is being displayed there is an icon that lets you export the report to Word or Excel.

But first you have to create a query, and link the report to the query.

Does this help you?
 
Upvote 0
can i create a template in Excel for the data in Access to go into, so it can then be calculated,etc.? If so, how?
 
Upvote 0
you can write SQL in Excel VB quite easily - ie. you can query your Access tables direct from Excel and create a SQL Query to return the data

eg

Set dbs = OpenDatabase("R:currentinfoPODatabaseFINANCE_DATA.mdb")

Set qry = dbs.CreateQueryDef(A, "SELECT TRAN_NUMBER, DATE, NOMINAL_CODE, DETAILS, DEPT_NUMBER, " & CURR & ", TYPE, YYMM FROM DATA WHERE NOMINAL_CODE IN ('0030', '0040', '6201', '6202', '6203', '6204', '6205', '6206', '6207', '6900', '7005', '7006', '7007', '7008', '7009', '7100','7103','7104', '7200','7203','7300','7304','7400','7401','7402','7403','7404','7406','7500','7501','7502','7504','7505','7506','7600','7601','7602','7603','7604','7605','7606','7700','7701','7800','7801','7802','7803','7900','7901','7902','8200','8201','8202','8203','8204','8205','8206','8207') AND DEPT_NUMBER in (" & "'" & DEPT1 & "'" & "," & "'" & DEPT2 & "'" & ")" & " AND YYMM in (" & "'" & Q_MTH1 & "'" & "," & "'" & Q_MTH2 & "'" & "," & "'" & Q_MTH3 & "'" & ")" & "")

Set rst = qry.OpenRecordset()

[a2].CopyFromRecordset rst

dbs.Close


The above example includes some variables set up earlier in the Macro - say DEPT1 = 10 then the syntax for the SQL would be

"'" & DEPT1 & "'"

so its read as '10'

etc...

The resulting data is then returned to the active sheet into range A2. Needless to say the actual Query may be far simpler than the above example - i.e. "SELECT DATA1 FROM TABLE1 WHERE MREXCEL = 'ME'"

NOTE: You will need to reference the DAO 3.6 Library and the Microsoft Access 9.0 (or 10.0 for XP) Library in your VB References.

Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,221,499
Messages
6,160,169
Members
451,629
Latest member
MNexcelguy19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top