Microsoft KB Archive/257947

= PRB: Runtime Error 7 : Out of Memory Error Message Occurs When BoundText Property of Data Combo Control Is Accessed in VB Code =

Article ID: 257947

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 3
 * Microsoft Visual Basic 6.0 Enterprise Edition Service Pack 4
 * Microsoft Visual Basic 6.0 Professional Edition

-



This article was previously published under Q257947



SYMPTOMS
If you try to access the BoundText property of a Data Combo control in Visual Basic code after you scroll down the list of elements in its list portion until the currently selected element is no longer visible in the list, the following error message is displayed:

Runtime Error '7': Out of Memory



CAUSE
The cause of this behavior is unknown.



RESOLUTION
Write code in the Click event of the Data Combo to store the value of the its BoundText property in a form-level variable. Use the form-level variable to access the value of the Data Combo's BoundText property.



Steps to Reproduce Behavior
The following steps reproduce this error:  Open a new Data project in Visual Basic. Drag-and-drop a Data Combo control, two ADO Data controls, and a CommandButton onto the form that is added to the project (frmDataEnv). Set the Style property of the Data Combo to one of the following:  dbcDropdownCombo dbcDropdownList

 Set the ConnectionString property of the first ADO Data control (ADODC1) to connect to the Nwind.mdb database that is located in the Visual Basic 98 folder. Specify the Products table in the Nwind.mdb database as its RecordSource.</li> Set the ConnectionString property of the second ADO Data control (ADODC2) to also connect to the Nwind.mdb database that is located in the Visual Basic 98 folder. Specify the Suppliers table in the Nwind.mdb database as its RecordSource.</li> Set the following properties of the Data combo as specified below:  DataSource - ADODC1</li> DataField - SupplierID</li> RowSource - ADODC2</li> ListField - CompanyName</li> BoundColumn - SupplierID</li></ul>

</li>  Cut-and-paste the following line of code into the Click event of the CommandButton: MsgBox DataCombo1.BoundText </li> Save and run the Visual Basic project, and note that the Data Combo displays a List of CompanyNames from the Suppliers table.</li> Click the drop-down button on the Data Combo to display the list portion of the control, and then scroll down the list of items by using the vertical scroll bar until the currently selected element in the Data Combo is no longer visible in the elements that are displayed in the list portion of the control.</li> Click the CommandButton, and note that this collapses the list portion of the Data Combo control and generates the run-time error message noted in the "Summary" section of this article. Stop the execution of the project and return to the Visual Basic environment.</li>  Declare a string variable by the name of BoundText in the form's General Declarations section. Cut-and-paste the following line of code in the Click event procedure of the Data Combo: BoundText = DataCombo1.BoundText </li> Modify the MsgBox statement in the Click event procedure of the Command Button to display the value of the BoundText variable instead of the BoundText property of the Data Combo.</li> Repeat steps 8 through 11, and note that the error message does not occur and that the value of the variable that is displayed reflects the value in the BoundText property of the Data Combo control.</li></ol>

Additional query words: DataGrid Runtime 7

Keywords: kbprb KB257947

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.