PRB: Run-Time Error Message '91' Occurs on Attempt to Access Recordset Object of Unbound ADO DataControl (266730)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q266730 SYMPTOMS
When you attempt to access the Recordset object of an ADO DataControl whose Connection and RecordSource properties have been set, the following error message results when the ADO DataControl does not have any controls bound to it:
Run-time error '91': Object variable or With block variable not set
CAUSE
The Connection and Recordset objects of the ADO DataControl do not get implicitly initialized unless the DataControl is bound to a control on the form that contains it.
RESOLUTION- Bind the ADO DataControl to a control on the form before attempting to access its Recordset object. You can then set the visible property of the control to False if you do not want the control to be displayed at run time.
- Call the ADO DataControl's Refresh method prior to accessing its Recordset object if you do not wish to bind the ADO DataControl to any control on the form. Typically, an ADO DataControl is used when there is a requirement to have data bound controls on a form. Writing Visual Basic code to create and use an ADO Recordset instead of using an ADO DataControl is another option to consider if data bound controls are not required.
STATUS
This behavior is by design.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbprb KB266730 |
---|
|