Microsoft KB Archive/163029

= FIX: Default Value Does Not Update Table in Local/Remote View =

Article ID: 163029

Article Last Modified on 10/15/2003

-

APPLIES TO


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

-



This article was previously published under Q163029



SYMPTOMS
In Visual FoxPro 3.0b, when a view is created and default value is set using DBSETPROP, the newly-appended records contain the default value in a Browse/Append window; but the default values disappear after TABLEUPDATE and REQUERY.



RESOLUTION
Instead of using default value in a view, manually code some ON KEY LABEL that inserts the default values when appending a new record. Since this bug is fixed in Visual FoxPro 5.0, the best way to avoid it is upgrading to Visual FoxPro 5.0.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Visual FoxPro 5.0.



Steps to Reproduce Behavior
  Copy and Paste the following code, and save this file as Prog1.prg under C:\KBTEST CLOSE DATABASES SET DEFAULT TO C:\KBTEST

* Create a database and open it

IF NOT FILE('Table1.dbf') CREATE DATA Data1 CREATE TABLE Table1 (ID C (8) Primary Key, State C (2)) SET MULTILOCKS ON        =CURSORSETPROP('Buffering', 5, 'Table1' ) ELSE OPEN DATABASE Data1 EXCLUSIVE ENDIF

* Create a view based on Table1

CREATE SQL VIEW View1 AS SELECT * FROM Table1

= DBSETPROP('View1.ID', 'Field', 'KeyField', .T.) = DBSETPROP('View1.ID', 'Field', 'UpdateName','Table1.ID') = DBSETPROP('View1.ID', 'Field', 'Updatable', .T.) = DBSETPROP('View1.State', 'Field', 'Updatable', .T.) = DBSETPROP('View1', 'View', 'SendUpdates', .T.)

* Set the view DefaultValue property = DBSETPROP('View1.State', 'Field', 'DefaultValue', "'WA'")

SELECT 0 USE View1 BROWSE  Run Prog1.prg. With the View1 Browse window open, append a records by pressing CTRL+Y, and then enter a unique ID value. Add several records this way. The default value of field STATE is automatically inserted as "WA." Close the View1 Browse window.  In the Command window, issue the following commands to refresh the update to Table1, and refresh View1 by retrieving data from Table1: = TABLEUPDATE(.T.) = REQUERY  Open the Table1 and View1 Browse windows. The STATE field value, "WA," of the newly appended records turns into blank.</li></ol>

Keywords: kbbug kbfix kbvfp500fix KB163029

-

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

© Microsoft Corporation. All rights reserved.