PRB: Default Values Not Written on Local ViewsID: Q131386 3.00 WINDOWS
The information in this article applies to:
SYMPTOMSWhen a table in a database contains default values and a blank record is appended to a local view based on that table, the defaults are not input into the fields automatically. If the view is closed and reopened, the default values are displayed.
CAUSEThe default clause in the database is part of the table definition. It is not defined when the local view is created. When the view is closed, the data is updated in the table, and default values are written.
RESOLUTIONYou can use the DBSETPROP() function to attach a default value to a field in a view. This will automatically insert a default value when a new record is appended. Use the following syntax to set a default value:
For more information about the DBSETPROP() function, search for DBSETPROP()
in the Visual FoxPro Help menu.
STATUSThis behavior is by design.
MORE INFORMATIONThe following code sample creates a local view that contains default values. To run this code, copy and paste it into a program. Then run the program. When the view is browsed, append records. The default values are inserted in the view.
Code SampleCLOSE DATABASES IF NOT FILE('testview.dbf') &&creates a database and opens it ELSE
ENDIF
* Creates a view and sets the view properties CREATE SQL VIEW myview AS SELECT * FROM testview =DBSetProp('myview.name','FIELD','DefaultValue',"'Smith'") =DBSetProp('myview.idnumber','field','keyfield',.T.) =DBSetProp('myview','view','SendUpdates',.T.) =DBSetProp('myview.idnumber','field','Updatable',.T.) =DBSetProp('myview.name','field','Updatable',.T.) =DBSetProp('myview.city','field','Updatable',.T.) SELECT 0 USE myview =DBSetProp('myview','view','tables','testview') BROWSE USE DELETE VIEW myview CLOSE DATA ALL Additional reference words: 3.00 VFoxWin KBCategory: kbprb KBSubcategory: FxtoolDbtabledes
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |