The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 3.0 and 3.0b
SYMPTOMS
When you use the same table in separate forms that have Private Data
Sessions, the ReadOnly property of a cursor is carried over from the first
session.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. This problem has been fixed in
Visual FoxPro 5.0 for Windows.
MORE INFORMATION
The following steps demonstrate the behavior. The behavior is specific to
the order in which you launch these forms. If you launch the ReadWrite form
first, issuing the APPEND BLANK command does in fact append a blank record
to the table and the record is visible in the grid on the ReadOnly form. On
the other hand, if you launch the ReadOnly form first, issuing the APPEND
BLANK command causes an error. Both these behaviors show that the Data
Session is not truly private.
Steps to Reproduce Problem
- Create a form and call it ReadWrite. Right-click the form, and select
Data Environment. Then right-click the Data Environment window, and
select Add.
- Select a table and add it to the Data Environment. Then select the table
in the Data Environment, and change its ReadOnly property to false (.F.)
in the Property Sheet.
- Select the form and change its DataSession property to 2 - Private Data
Session.
- Place a command button on the form, and change its Caption property to
Append. Then add the following code to its Valid event:
APPEND BLANK
- Create a second form, and name it ReadOnly. Right-click the new form,
and select Data Environment. Then right-click the Data Environment
window and select Add. Select the same table selected in step 2 and add
it to the Data Environment.
- Select the table in the Data Environment and change its ReadOnly
property to true (.T.) in the Property Sheet. Select the form and change
its DataSession property to 2 - Private Data Session. Drag the table
from the Data Environment to the ReadWrite form to create s grid.
- Run the ReadWrite form. Then run the ReadOnly form. Click the Append
button in the ReadWrite form. Then click the first blank record in the
grid on the ReadOnly form. Note that although you can click into the new
record and see the caret blinking there, you cannot enter data into the
blank record.
- Close both forms. With the USE command, open the table and delete the
added record. Then pack the table.
- Run the ReadOnly form. Then run the ReadWrite form. Note that you
reversed the order in which the forms were launched. Click the Append
button in the ReadWrite form. Note that the Trace window appears with
the Valid code of the command button exposed highlighting the line of
code that states:
APPEND BLANK
Also, an error occurs that states:
Cannot update cursor.
After you click Ignore, note that the grid does not have a blank record.
|