Microsoft Access
  Home arrow Microsoft Access arrow Page 3 - Scripting a Data Access Page: a Simple Exa...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MICROSOFT ACCESS

Scripting a Data Access Page: a Simple Example
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 10
    2006-05-30

    Table of Contents:
  • Scripting a Data Access Page: a Simple Example
  • Creating a data access page
  • Adding a script to this page
  • Saving and Displaying the Data Access Page

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Scripting a Data Access Page: a Simple Example - Adding a script to this page


    (Page 3 of 4 )

    We will add script to change the heading 'Test' to something different. We will change this heading to something that will depend on one of the columns in the database.  Review the next picture; it shows the result of a query which returns the values used in the DAP (this page).  There are various cities, including 'London.'  We will change the heading's text depending on the 'City' that is in view.

    What will the script accomplish?

    We will be creating a script to change the Label to 'Welcome to Heathrow' if the city is 'London,' or 'Welcome to World' for any other city at the click of a button. Instead of the click event of the button you may as well use any other multitude of events the DHTML allows.

    Now in the design view add a CommandButton as shown here. Change its Element Properties, innerText from Command1 (default) to 'London?' as shown.

    Now open up the Microsoft Script editor to see the document outline as shown. You can see the Command1 object in the Client Objects and Events folder.

    On an empty area of the page, right click to bring up the Document Property Pages as shown and change the default scripting language so that the client's default language is JavaScript (ECMAScript) as shown here. The default is VbScript.

    In an empty area of the page right click, and from the drop-down menu choose Insert Script Block -->Client as shown.  Please refresh your memory about the various windows in the script editor.

    This will allow you to write JavaScript/ECMA for the client. Now double click the Command1 button's click event in the Document window shown earlier. This adds the script shown in this picture.

    Now to the function of the command1 click add the following code.  

    function Command1_onclick() {
    alert("Will be formatting");
    alert(document.getElementById("HeadingText").outerHTML);
    var hd=document.getElementById("HeadingText");
    hd.style.color="magenta";
    hd.innerHTML="<h2>Welcome</h2>"
    //variable hd refers to the document's heading var 
    cty=document.getElementById("City_Label"); //similarly cty refers to the City_Label[different from City]
    cty.style.backgroundColor="lime"; var ctytxt=document.getElementById("City"); alert(ctytxt.innerHTML); // if(ctytxt.innerHTML=="London") { hd.innerHTML="Welcome to Heathrow"; } else{ hd.innerHTML="Hello world!"; } // var cn=document.getElementById("CompanyName_Label"); var con=document.getElementById("ContactName_Label"); cn.style.backgroundColor="lime"; con.style.backgroundColor="lime"; }

    More Microsoft Access Articles
    More By Jayaram Krishnaswamy


       · Using the built-in wizards you can do a lot, but with scripting you can do even...
     

    MICROSOFT ACCESS ARTICLES

    - Linking SQL Express 2005 Tables to MS Access...
    - Working with Access Projects in Access 2007
    - Exploring Access 2007
    - Working with Stored Procedures in an MS Acce...
    - Creating and Using Action Queries
    - Creating Data Access Pages with Charts using...
    - Advanced Ideas using VBA
    - VBA Details
    - Updating Records in MS Access
    - Using ADO`s Record Object with URLs
    - Exporting XML from MS Access 2003
    - Importing XML into MS Access 2003
    - On Using Pass-through Queries in MS Access
    - Distributed Queries in MS Access
    - Configuring a Linked Microsoft Access Server...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway