Microsoft KB Archive/145891

= PRB: Combo Box Moves Record Pointer When No Selection Was Made =

Article ID: 145891

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q145891



SYMPTOMS
When a form contains a combo box that has its RowSource set to the same table that other controls on the form are using as their ControlSource, the record pointer may move to a different record when the user activates the combo box. There are two different scenarios where this unwanted moving of the record pointer can occur. This article outlines both scenarios.



WORKAROUND
Use an SQL statement for the RowSource of the combo box.



STATUS
Microsoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
If you are not familiar with the Form Designer or with the different form controls, please see Chapters 9 and 11 in the Developer's Guide.

Steps to Reproduce Behavior
 Create a new form and add the Customer table (found in the Samples\Data directory) to the form's Data Environment. Drag the cust_id and company fields from the Customer table in the Data Environment onto the form.  Add a combo box (Combo1) to the form and set these properties: RowSourceType = 6 - Fields RowSource = Customer.Cust_id   Add the following code to the following indicated Combo1 events:

Init event: This.Value = Cust_id GotFocus event: SET ORDER TO Cust_id InteractiveChage event: ThisForm.Combo2.Value = This.Value   Add a second combo box (Combo2) to the form and set these properties: RowSourceType = 6 - Fields RowSource = Customer.Company,Cust_id BoundColumn = 2 ColumnCount = 2 ColumnWidths = 200,0   Add the following code to the following indicated Combo2 events:

Init Event: This.Value = Cust_id GotFocus Event: SET ORDER TO Company InteractiveChage Event: ThisForm.Combo1.Value = This.Value </li> Save and run the form.</li> After the form is up and running, click Debug on the Tools Menu. In the Debug window, enter RECNO.</li></ol>

Scenario Number One
Activate the drop down list in Combo1, and select BERGS. Look in the Debug window to see what record number you are on. Then click in the text area of Combo2 to place your mouse pointer in it. Look in the Debug window, and you will see that the record number has changed. Now place your mouse pointer back in Combo1, and you will see in the Debug window that the record number has moved back to what it was when you first made the selection in Combo1.

Scenario Number Two
Activate the drop down list in Combo1, and move your mouse pointer down the list until the last item in the visible list is highlighted. Without making a selection, click in one of the text boxes on the form. Look in the Debug Window, and you will see that the record pointer has moved. In both scenarios, if you were to activate one of the text boxes, you would see the value of the text box change to match what is stored in the record.

Additional query words: VFoxWin

Keywords: KB145891

-

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

© Microsoft Corporation. All rights reserved.