<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
Friday, August 01, 2008

Display Excel Value Directly on Form

We have already seen how to open dBase Files directly and work with the data in VBA in the earlier Post Opening dBase File Directly. But, there are other alternatives (besides linking the files) to work with dBase Files in Access. We will explore this aspect in detail later. This Post was originally intended for a demo of opening Excel based Data Table directly and working with it in VBA Code. We will do that in the next Post. Before that we will look into some interesting and very easy trick with Excel.


Why I said very easy, because you don't have to struggle with VBA Code to do this. I know you will be happier if you don't have to work with my spaghetti VBA Code. So, I thought we will take a break and do something different and interesting before continuing with databases.


You got the clue from the title itself. That's right, you can display Values from Excel Worksheet directly on Microsoft Access Forms. We will go straight into a Demo.


  1. Open Microsoft Excel.

  2. Enter your name in Cell A1 on Sheet1 and minimize Excel, don't close it. You may save the Workbook with a name before minimizing it. The WorkBook may keep interrupting for saving it, if Auto-save feature is on.

  3. Open any one of your Microsoft Access Databases or create a new one.

  4. Open a New Form in Design View.

  5. Select the Text Box Tool from the Tool Box and draw a Text Box on the Detail Section of the Form.

  6. Click on the Text Box and display the Property Sheet (View - -> Properties).

  7. Write the following expression in the Control Source Property of the Text Box:


  8. =DDE("Excel","Sheet1","R1C1")

  9. Save the Form with a name of your choice.

  10. Open the Form in Normal View. You will see your Name written on Excel Cell is appearing in the Text Box on the Form.


  11. The DDE() Function stands for Dynamic Data Exchange. The first two Parameters are Excel Application and worksheet name Sheet1 and the third one is the Cell Reference where your name is written in R1C1 (Row-1 Column-1 or Cell A1). The Cell reference must be used in this way rather than A1 style.


    But, there are chances that you may end up with nothing showing on the Text Box. In that case you have to see a particular Option is correctly set in the General Tab of Options… in Excel Tools Menu.

  12. Click on the Excel icon on the Taskbar to open it. Click on Tools - -> Options… and select the General Tab.

  13. Remove the check mark (if it is set) from the option Ignore Other Applications under the Settings Options.

  14. Minimize Excel, Close MS-Access Form and open it again. Now you must see your name from the Excel Cell on the Form. Don't close the Form.

  15. Maximize Excel again and make some change in your Name and Minimize again. The change may not reflect immediately on the Form. You can update the Form value manually without closing and opening the Form again.

  16. While the Access Form is in Normal View, select OLE/DDE Links from Edit Menu.

  17. The Links Dialog Box will open up. Select DDE Links in the Links Group control. The Link's list will appear below. Select the Link and click on the Update Now Command Button. Now the change on the Worksheet will reflect on the Form Value.


There are Option settings in MS-Access also similar to the one we have made in Excel. The general rule is that instead of refreshing the change manually, as we did above, it should happen automatically at a fixed interval as per the Tools - - > Option… settings in Microsoft Access, but I didn't see it happen successfully on my machine so far.


Select Tools - -> Options… - -> Advanced Tab. Put a check mark in Enable DDE Refresh option, if it is not set. You can see the default Values set for automatic refreshing for Dynamic Data Exchange and ODBC links, how many retries and in case of failures how long Microsoft Access should wait before trying again etc.


You can display Values from Excel in two more Access Controls, in Combo Boxes and Option Group Control. See the sample image given below.



image of Dynamic Data Exchange



  1. Minimize Access and Maximize Excel.

  2. Enter few Names of people, books or anything else in Cells A9 to A17.

  3. Enter Value 2 in Cell C1 and minimize Excel Application Window.

  4. Maximize MS-Access and open the Form in Design View.

  5. Disable the Control Wizards Button (top right button, if it is active) on the Tool Box. Select the Combo Box Tool and draw a Combo Box Control on the form in such a way that it looks like a List Box. See the sample image given above.

  6. Display the Property Sheet and write the expression


    =DDE(“Excel”,”Sheet1”,”R9C1:R17C1”)


    in the Control Source Property of the Combo Box.


  7. You may give a Name to the Range: R9C1:R17C1 and use that Name in the expression replacing the Range Address. To Name the Excel Cell Range, highlight the Range, select Insert - -> Name - -> Define and type the name, say List, in the Names in Workbook control. Replace the third Parameter R9C1:R17C1 with the Range Name List in the DDE Function.


  8. Open the Form in Normal View. The Names from the Excel Range will appear in the Combo Box.


Note:You cannot select any of these values and insert into the Text Box portion of the Combo Box and use it in a data field.


We will try one more example with the Option Group Control.


  1. Turn On the Control Wizard on the Tool Box. Select the Option Group Tool from the Tool Box and Draw an Option Group Control on Form. Refer the example given above.

  2. Type three Labels in the Wizard: Data View, Print Preview and Print, or anything else you prefer, on the control and Click Finish.

  3. Click on the outer frame of the Option Group and display the Property Sheet (View - -> Properties).

  4. Write the following expression in the Control Source Property:


=DDE("Excel","Sheet1","R1C3"


The selection of item on the Option Group will be based on the Value given in the Excel Cell C1. Now the value in Cell C1 is 2. The second item on the Option group will now show as selected. Change the Value in Cell C1 to 3 and refresh the Form as explained above, the option will change to 3.


Note: If the Excel Application is not active when you open the Form with the DDE() Function then Access will show the following Error Message:


"You tried to open a form or report that includes a DDE or DDESend function in a calculated control that specifies an OLE server application."

"Do you want to start the application Excel?"



If you respond with Yes then Excel Application will be started with Blank Sheets. You must open the Excel Workbook that provides information for DDE() Function manually to show up the values in Access Form.



StumbleUpon Toolbar



Database Open Close Event Alerts
ListBox Items and Date:Part-2
ListBox Items and Date:Part-1
Create ListBox from Another one
Selected List Box Items and Dynamic Query

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