PRB: Datatype Error Accessing Property With _Access Method

ID: Q194202


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 6.0


SYMPTOMS

Returning an invalid datatype in the _Access method of an object's property results in the following error when you reference that property:

Datatype is invalid for this property.


RESOLUTION

To avoid this error, make sure that the datatype returned is valid for the property being accessed.

It is recommended that the return value of the _Access method be the property's value.

Example:


   PROCEDURE object1.INTERVAL_Access
      RETURN THIS.INTERVAL
   ENDPROC 
In the rare instance where you need to return a value other than the property's value, changing the value of the property, and returning the property ensures that you are storing the value for future comparison.

NOTE: You should consider changing the value of a property in the property's _Access method an extreme case, and make sure you fully document the change.


STATUS

This behavior is by design.


MORE INFORMATION

NOTE: The example we provide in this article is not the only place this behavior occurs. Any access method that tries to return an invalid datatype for the property fails with the error.

Steps to Reproduce Behavior

Run the following sample code from a program file.

Notice that the RETURN statement in the object1.INTERVAL_access method returns nothing explicitly. In Visual FoxPro, unless you specify what to return, FoxPro returns a logical true or false (.T. or .F.). This is not a valid setting for the Interval property of the Timer object. This results in the error "Datatype is invalid for this property," and Visual FoxPro cannot instantiate the object.

      *******Begin Sample Code************

      PUBLIC oDS
      oDS=CREATEOBJECT("test")
      oDS.SHOW
      READ EVENTS
      USE
      RELEASE oDS

      DEFINE CLASS test AS FORM
         DOCREATE = .T.
         CAPTION = "Now Testing Access for Object TIMER"
         ADD OBJECT object1 AS TIMER
         ADD OBJECT btnClose AS COMMANDBUTTON
         PROCEDURE object1.INTERVAL_access
            RETURN
         ENDPROC
         PROCEDURE btnClose.CLICK
            CLEAR EVENTS
            RELE THISFORM
         ENDPROC
      ENDDEFINE

      *********End Sample Code******** 

Additional query words: kbVFp600 kbOOP

Keywords :
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: December 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.