Microsoft KB Archive/258017

= FIX: FieldChangeComplete Not Fired When UserControl Loses Focus by Mouse-Click =

Article ID: 258017

Article Last Modified on 8/7/2007

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q258017



SYMPTOMS
Using a UserControl control that contains another usercontrol and a TextBox control, which is bound to a Field object of an ADO Recordset object, the FieldChangeComplete event of the ADO RecordSet object is not fired after the TextBox control has a change and loses its focus to the contained usercontrol by mouse-clicking.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.

For additional information about Visual Studio service packs, click the following article numbers to view the articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed

To download the latest Visual Studio service pack, visit the following Microsoft Web site:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx



Steps to Reproduce Behavior
 Start a new ActiveX control project. UserControl1 is added by default. Change the name of UserControl1 to MyControl . Place a Label on MyControl and change its caption to MyControl. Size MyControl so that it is nearly the same as Label. Close the MyControl window. From the File menu, choose Add Project. Project2 is added with Form1 by default.</li> Right-click on Project2 and then click on Set as Start up.</li> From the Project menu, choose References, and then add references by checking the following items for Project2: <ul> Microsoft ActiveX Data Objects 2.1 Library</li> Microsoft Data Binding Collection</li> Microsoft Data Source Interfaces</li></ul> </li> From the Project menu, choose Add User Control. UserControl1 is added by default.</li> Place two TextBox controls, one MyControl and one Label on UserControl1. Make the TextBox controls relatively long.</li>  Paste the following code into UserControl1's code window: Private colBndNwind As New BindingCollection Private WithEvents rs As ADODB.Recordset

Public Sub Init Set rs = New ADODB.Recordset With rs       .Fields.Append "Text", adChar, 20 .Open .AddNew .Fields.Item("Text") = "Text" End With ' Set the DataSource of the Bindings collection to the recordset. Set colBndNwind.DataSource = rs  ' Add to the Bindings collection. With colBndNwind .Add Text1, "Text", "Text" End With Text2.ForeColor = 255 End Sub

' Called after the value of Field objects has changed. Private Sub rs_FieldChangeComplete(ByVal cFields As Long, ByVal Fields As Variant, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) Text2.Text = "FieldChangeComplete: " & Fields(0).Name & " = " & Fields(0).Value End Sub </li> Close the UserControl1 window.</li> Place one UserControl1 on Form1.</li>  Paste the following code into Form1's code window: Option Explicit

Private Sub Form_Load UserControl11.Init End Sub </li> Press the F5 key to run the program.</li> Click on the TextBox that has Text, and type Hello. Click on MYCONTROL, and note that the FieldChangeComplete event is not fired because the other TextBox's text has no change.</li> Click on the TextBox again and type Hey. Click on Label1, and note that the FieldChangeComplete event is fired because the other TextBox is changed.</li> Click on the TextBox again and type Hi. Press the TAB key, and note that the FieldChangeComplete event is fired because the other TextBox is changed.</li></ol>

Keywords: kbactivexevents kbbug kbctrlcreate kbfix kbvs600sp4fix kbvs600sp5fix KB258017

-

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

© Microsoft Corporation. All rights reserved.