Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 163029 - Last Review: October 15, 2003 - Revision: 3.1
FIX: Default Value Does Not Update Table in Local/Remote View
This article was previously published under Q163029
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().
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.
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.
APPLIES TO
- Microsoft Visual FoxPro 3.0b Standard Edition
- Microsoft Visual FoxPro 3.0b for Macintosh
| kbbug kbfix kbvfp500fix KB163029 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please