Microsoft KB Archive/143421

= How To Synchronize Data on the Form with a dbCombo =

Article ID: 143421

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q143421



SUMMARY
You can use the DBCombo control to link data from two data controls if the DataField property of the DBCombo control uses a field common to the RecordSource of the data controls. The FindFirst method allows you to synchronize the data between the two data controls when the DataField property of the DBCombo control is linked to a primary key.



MORE INFORMATION
The following code example allows you to synchronize data between two data controls when the DBCombo control is bound to a field common to both data controls. The field is a primary key.

Code Example
 Start 16-bit or 32-bit Visual Basic or if it is already running, click New Project on the File menu.  Add the listed controls to the Form and set the indicated properties      Control     Default Name   Property           Value ---

Data       Data1          DatabaseName       Biblio.mdb RecordSource      Publishers

Data       Data2          DatabaseName       Biblio.mdb RecordSource      Titles

TextBox    Text1          DataSource         Data1 DataField         PubID

TextBox    Text2          DataSource         Data1 DataField         Name

TextBox    Text3          DataSource         Data1 DataField         Company Name

TextBox    Text4          DataSource         Data2 DataField         Title

DBCombo    DBCombo1       DataSource         Data2 RowSource         Data1 BoundColumn       PubID DataField         PubID ListField         PubID Style             2 - DropDown List

  Copy the following code to the Code window of the Form1 form to do the synchronization: Private Sub DBCombo1_Change Data1.Recordset.FindFirst "PubID=" & DBCombo1.BoundText End Sub

Private Sub Form_Load Data1.Refresh End Sub

 On the Run menu, click Start or press the F5 key to start the program. Select a number from the ComboBox control and note that all the text boxes change. The ComboBox control and the first text box match showing the synchronization.

Keywords: kbhowto kbctrl KB143421

-

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

© Microsoft Corporation. All rights reserved.