Microsoft Knowledge Base Email Alertz

(304724) - This article shows you how to use ActiveX Data Objects (ADO) to access the RecordsetDefs object of a data access page and to list its contents.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 304724 - Last Review: September 27, 2006 - Revision: 4.2

ACC2002: How to Return an ADO Recordset from a RecordsetDef on a Data Access Page

This article was previously published under Q304724
Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SUMMARY

This article shows you how to use ActiveX Data Objects (ADO) to access the RecordsetDefs object of a data access page and to list its contents.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Open the Northwind sample database.
  2. In the Database window, click Pages under Objects, and then click New to create a new data access page.
  3. In the New Data Access Page dialog box, click AutoPage: Columnar, click the Customers table in the Choose the table or query where the object's data comes from box, and then click OK.
  4. Save the new page as Customers.htm.
  5. Open the Customers page in Design view, and then add a command button to the header section of the Customers page.
  6. In the property sheet for the command button, change the InnerText property to View with ADO.
  7. Save the page.
  8. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  9. On the View menu, point to Other Windows, and then click Document Outline.
  10. In the Document Outline window, expand the Client's Objects & Events folder, and then double-click the onclick event for the Command0 button. This will insert the VB Script that defines the onclick event for the Command0 button into the Customers.htm page. The inserted VB Script will look similar to the following:
    <SCRIPT language=vbscript event=onclick for=Command1>
    
    <!--
    
    -->
    
    </SCRIPT>
    					
  11. Copy and paste the following VB script between the <!-- and --> markers.
      Dim rs
      Dim rsDef
      Dim LoopCnt 
    
      LoopCnt = 0
      rsDef = MSODSC.RecordsetDefs.Item(0).Name 
      Set Rs = MSODSC.Execute(rsDef) 
    
      Rs.MoveFirst 
      MsgBox "Company: " & Rs("CompanyName") & vbNewLine & "Contact: " & Rs("ContactName") & _
     vbNewLine & "Phone: " & Rs("Phone") 
    
       Set Rs = Nothing 
    					
  12. Save your changes to Customers.htm, and then preview the data access page.

REFERENCES

For more information about RecordsetDefs, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type recordsetdefs in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

APPLIES TO
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbdta kbhowto KB304724
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate