Microsoft KB Archive/187274

= FIX: Referencing This.Value in Editbox Refresh Causes Error =

Article ID: 187274

Article Last Modified on 6/6/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q187274



SYMPTOMS
Referencing This.Value property in the Refresh event of the Editbox object causes a memory protection error in Visual FoxPro. Under Windows 95, an application error appears indicating an invalid page fault occurred. in Windows NT 4.0, a Dr. Watson for Windows NT dialog box appears that states that an application error occurred, and that Visual FoxPro caused an exception violation at a specific memory address.



RESOLUTION
Call the DODefault method of the Editbox before the This.Value command in the Refresh event. In the code example below, change the Refresh event code to read as follows: PROCEDURE Refresh IF THISFORM.chkRef.Value DODEFAULT WAIT WINDOW THIS.Value NOWAIT ENDIF RETURN ENDPROC



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual FoxPro for Windows 7.0 and later.



Steps to Reproduce Behavior
  Create a program that contains the following code, and then run the program: CLOSE ALL

CREATE CURSOR Test (Field1 M, Field2 C(12), Key N(2)) INSERT INTO Test (Field1, Field2, Key) VALUES ; ("This is some text.","More", 1) INSERT INTO Test (Field1, Field2, Key) VALUES ("", "Other", 2) CREATE DATABASE Test CREATE SQL VIEW "TestView" AS SELECT * FROM Test WHERE Key = ?m.Key

Key = 1 USE TestView

PUBLIC ox     ox=CREATEOBJECT("frmTest") ox.Visible = .T.

RETURN

DEFINE CLASS FrmTest AS FORM ADD OBJECT edtField1 AS edtField1 ADD OBJECT txtField2 AS txtField2 ADD OBJECT cmdButton AS cmdButton ADD OBJECT chkRef AS chkRef

ENDDEFINE

DEFINE CLASS chkRef AS CheckBox Top = 190 Width = 200 Left = 20 Caption = "Refer to the Value in the Refresh" Value = .F.     ENDDEFINE

DEFINE CLASS cmdButton AS CommandButton Top = 20 Height = 30 Left = 200 Caption = "Another Record" PROCEDURE Click Key = TestView.Key + 1 IF m.Key > RECCOUNT("Test") Key = 1 ENDIF =REQUERY("TestView") THISFORM.Refresh RETURN ENDPROC

ENDDEFINE

DEFINE CLASS txtField2 AS TextBox Top = 20 Height = 30 Left = 20 ControlSource = "TestView.Field2" ENDDEFINE

DEFINE CLASS edtField1 AS EditBox Top = 100 Left = 20 ControlSource = "TestView.Field1"

PROCEDURE Refresh IF THISFORM.chkRef.Value WAIT WINDOW THIS.Value NOWAIT ENDIF RETURN ENDPROC

ENDDEFINE  When the form appears, click the check box and then press the command button. The error message appears.

Additional query words: kbDSupport KBDSE crash hang gpf kbVFp500bug

Keywords: kbbug kbpending KB187274

-

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

© Microsoft Corporation. All rights reserved.