<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Thursday, August 21, 2008

MS-Access Live Data in Excel

We have already learned tricks to open and work with external data sources like Access Table, dBase Files and Excel Table without linking them permanently. We have tried VBA and Query based methods too.


We have yet to try the ODBC connection string in Source Connect Str Property in a Query to open external data files with this method. Even though we can link external data into MS-Access manually we will be trying the VBA based method for linking external files later.


But, before going into all that we will try a different trick, for a change in the one way traffic, so to speak, of data flow from external data sources into Access. But it is not exactly one way data flow into Access we can update external data from within Access, with or without direct links.


The Data Sources that we have opened after setting Source Database and Source Connect String Properties in Queries are updatable. The changes which you make on these data sets from within MS-Access will be updated back in their respective parent Applications.


Here, we will try linking live MS-Access Data in Excel and see that it stays live reflecting changes made in MS-Access. MS-Access will function as the Server Application and MS-Excel will be at the Client side.


There is only one difference, when compared with the earlier methods we tried, the changes that you make on Access data in Excel, which you are allowed to do, will not be updated back in Access.


Then what do we do with the Access Data in Excel? Well, you can create Charts or do calculations or whatever you like if you are more comfortable with Excel based tasks. You can create links to the data (Copy- -> Paste Special- ->Paste Link) from other Part of the Workbook and use the data for Charts or Reports, instead of making direct change on the linked source data. The changes that takes place in Access will automatically reflect on the Report or Chart in Excel.


For brining Access Data into Excel we need another Application, Microsoft Query, as a go between, to connect to Access Table. The Query Wizard will guide us through various options to link with Access, when we start with the Data options in Excel.


We will use the Categories Table from Northwind.mdb sample Database for our example.


  1. Open a new MS-Excel Workbook.

  2. Select Cell A1 on Sheet1.

  3. Point to Import External Data in Data Menu.

  4. Select New Database Query from the displayed Menu.


  5. Now, Microsoft Query Wizard Opens up and displays a Dialog Box. It displays the Database Sources in the Databases Tab that you can link to MS-Excel. This is a combined list of items appearing in the ODBC Dialog Control User DSN, System DSN and File DSN Tabs.



    Microsoft Query Wizard image


  6. Select MS-Access Database* from the list and click OK.

  7. The Common Dialog Control opens up allowing you to browse to the Location of MS-Access Database and select it. Find the sample database C:\Program Files\Microsoft Office\Office11\Sample\Northwind.mdb (MS-Access 2003, you can drop 11 from Office11 in location address for Access 2000), select and click OK.


  8. Select the Categories Table from the Available Tables and Columns in the Query Wizard and click on the > symbol to select all the Fields of the Categories Table into the Columns in your Query Control. If you don't need all the fields from the Source Table then you can expand the Categories Table by clicking on the + symbol to display all the Fields and select only those you need and move it to the right side.


  9. Microsoft Query Wizard image-2

    Before you move the field to the right you can preview the Field contents by clicking the Preview Now button below. Memo Field or OLE Object field contents cannot be previewed this way.

  10. After selecting the Fields Click Next. Here, you can define Filter conditions.


  11. Query Wizard Filter Conditions


  12. Click Next to proceed to the Sort options.



  13. Query Wizard Sorting Options


  14. Click Next to move to the Finishing point.


  15. Here, we have the option to save the selected settings in a Microsoft Query (which is an external File) at location C:\Documents and Settings\User\Application Data\Microsoft Queries\. If we need any changes in the data selection options then we can open this saved file in Microsoft Query and edit the Query Definition in SQL Window.



    Query Wizard Finish Options


  16. See the Radio Button is set on Return Data in Microsoft Office Excel and click Finish.

  17. In the next Dialog Control you can select the Location on the Excel Sheet, where you want to insert the Data from Access. Since, we have already selected Cell A1 as target location in Step-2 above, this will appear as default location in the control, click OK without change.



Target Location Selection


The records from Categories Table will be inserted in Excel starting from range address A1.


It was a long journey from Access to Excel. Bringing Excel data into Access only need two property changes in MS-Access Query and you know now how simple it is.

Since, we are successful in bringing Access data into Excel let us do some experiments to prove that it is really live data from Access and how the changes made in Access reflects here.

There are two methods to refresh Access Data in Excel, Manual and Automatic.


Keep the Northwind.mdb sample database open so that we can make changes in the linked table in Excel or in Access and check the results of the change in both Applications.


  1. Open the Categories Table of Northwind.mdb Database.

  2. Add Crabs, Lobsters in the Description field of the last Record. Or add a new record with some Category Name and Description.

  3. Minimize MS-Access and Display Excel Window and check whether the change has taken place immediately in the linked data in Excel. You may not find any change in Excel side. We have to refresh the data in Excel to reflect the changes.

  4. Click anywhere within the data Area.

  5. Select Refresh Data from Data Menu.


  6. Now the changes that you have made will be updated in the Excel side too. We can tell Excel to do this job automatically at a fixed interval rather than doing it manually.


  7. Right-Click somewhere in the middle of the Linked Table and select Data Range Properties from the displayed Shortcut Menu.

  8. On this Control you will find several options to manage the Data including the Query Name that transports the Data from Access to Excel. Select the Radio Button in the Refresh Every option under the Refresh Control Option Group and set the time 1 Minute, so that we can watch the refreshing action without waiting it for too long to happen.

  9. Open the Access window and remove the changes that we have made in the Categories Table, or make some more changes so that they are clearly visible in Excel when automatic refreshing action takes place.

  10. Open Excel window and wait for the Refresh Action to take palce. The change might have already taken place or it may happen any time because Excel will continue refreshing the change every minute.


If you have made any changes in the Excel side of the data then that will be lost in this process.


If you close the Excel Workbook and open it again a prompt will pop-up asking you to re-confirm whether Excel should automatically do the refreshing of linked data or not. You may respond the way you want it.


We will continue our discussion on few more points on this subject in the Next Post, instead of crowding everything in here.



StumbleUpon Toolbar



Working With Chart Object in VBA
Linking with AS400 Tables
Repairing Compacting Database with VBA
Database Open Close Event Alerts
ListBox Items and Date:Part-2

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com