MOD2000: Error Binding Recordset to RowSource Property of DataList or DataCombo Control

ID: Q236469


The information in this article applies to:
  • Microsoft Office 2000 Developer
  • Microsoft Access 2000


SYMPTOMS

When you add a DataList or DataCombo control to a UserForm, you are unable to bind the control to a recordset at design time. When you try to bind a recordset to the RowSource property of the control at run time, you receive the following error message:

Run-time error '438':
Object doesn't support this property or method


CAUSE

This problem occurs because the RowSource property of the control conflicts with the built-in RowSource property of the UserForm.


RESOLUTION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
In order to bind a DataList or DataCombo control to a recordset, you must explicitly dimension a variable of the type of control that you are working with, and then set the variable to the control on your UserForm. The following example illustrates this technique:

NOTE: This example assumes that your UserForm contains a DataList control named DataList1 and an ADO Data Control named Adodc1.

Dim dlDataList as DataList

Set dlDataList = DataList1
Set dlDataList.RowSource = Adodc1 


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Excel 2000.


  2. On the Tools menu, point to Macro, and then click Visual Basic Editor.


  3. On the Insert menu, click UserForm. This adds a blank UserForm to your project.


  4. On the Tools menu, click Additional Controls.


  5. Click to select the Microsoft ADO Data Control, version 6.0 and the Microsoft DataList Control, version 6.0 check boxes.


  6. Click OK to close the Additional Controls dialog box.


  7. View the control toolbox by clicking Toolbox on the View menu.


  8. Add the ADO Data Control and the DataList control to the UserForm.


  9. Right-click the ADO Data Control, and then click Properties.


  10. Click in the Custom property box, and then click the Build (...) button next to the Custom property to display the control's Property Pages dialog box.


  11. In the Property Pages dialog box, click the General tab.


  12. Click Use Connection String, and then click Build.


  13. In the Data Link Properties dialog box, click Microsoft Jet 4.0 OLEDB Provider, and then click Next.


  14. Enter the path to a valid Jet 4.0 database on your computer, such as the sample database Northwind.mdb that is included with Microsoft Access, and then click OK.


  15. In the Property Pages dialog box, click the RecordSource tab.


  16. Under CommandType, click adCmdTable, and under Table or Stored Procedure Name, select a valid table name.


  17. Click OK to close the Property Pages dialog box.


  18. On the View menu, click Code to view the module of the form.


  19. Add the following code to the module of the form:


  20. 
    Option Explicit
    
    Private Sub UserForm_Initialize()
      DataList1.RowSource = Adodc1
    End Sub
     
  21. On the Run menu, click Run Sub/UserForm.


Note that you receive the error message mentioned in the "Symptoms" section of this article.

Additional query words: pra prb

Keywords : kberrmsg kbdta kbdtacode AccCon modDesigners
Version : :; WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 18, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.