Microsoft KB Archive/189998

= BUG: Data Environment: MSHFlexGrid Rebinding Data =

Article ID: 189998

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q189998



SYMPTOMS
Attempting to rebind the MSHFlexGrid to a different Data Environment as the DataSource property results in an error:

Runtime Error 30022, The Hierarchical FlexGrid does not support the requested type of data binding.



CAUSE
If the MSHFlexGrid.DataMember is set to a Data Environment other than the original, the MSHFlexGrid attempts to rebind the data using the previous DataSource property setting. Because the same Command does not exist in the subsequent Data Environment, an error results.



RESOLUTION
To work around this problem, set MSHFlexGrid.DataSource = Nothing before rebinding to the next Data Environment.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
 Create a new Visual Basic Standard.Exe project.Form1 is created by default. From the  menu, check the selection for . Add a MSHFlexGrid to the form. From the <Project-Add Data Environment> menu, create a new Data Environment.</li> Right-click the Connection icon and, under the Provider tab, select <Microsoft Jet OLEDB Provider>. On the Connection tab, click the ellipse button, choose the NWind.MDB, and then click OK.</li> Right-click the Connection icon again, and select <Add Command>.</li> Right-click on Command, and select <Properties>. Select <Table> as the database object source, and select <Employees> for the Object Name.</li> Right-click the Command icon and select <Rename>. Rename the Command to .</li> Repeat steps 4-7 to create a second Data Environment. Do not rename the second Command.</li>  Add two CommandButtons to the form and paste the following code into each respectively. Private Sub Command1_Click 'Set MSHFlexGrid1.DataSource = Nothing MSHFlexGrid1.DataMember = "test1" Set MSHFlexGrid1.DataSource = DataEnvironment1 End Sub

Private Sub Command2_Click 'Set MSHFlexGrid1.DataSource = Nothing MSHFlexGrid1.DataMember = "command1" Set MSHFlexGrid1.DataSource = DataEnvironment2 End Sub

</li> Run the project and click on ommand1. The MSHFlexGrid should be populate with the results. Click on Command2. You should receive an error indicating:

The Hierarchical FlexGrid does not support the requested type of data binding.

</li> Uncomment the commented out lines in the CommandButtons. Repeat step 11. You should not receive an error attempting to rebind the Data Environment.</li></ol>

<div class="references_section">