Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Property error

Status
Not open for further replies.

CleoMan

Programmer
Jun 18, 2003
110
ZA
When my form loads I get the following error.

Setfocus event: " A error occured when setting the property named 'Color' of the object named 'Button 32' of type 'button'"

It's obvious what the problem is but how do I fix this error? Why does it occur, becuase only last week the same form opened without any problems/error.

PS: I am sorrry for asking all these stupid questions, but time is little and I've only been working on Paradox for 5 months so be forgiving :)

Thanks.
Richard
 
Did you click the '>>' button on the error dialog box? It provides a little more detail.

I don't think there is a 'Color' property on buttons. The closest you can get is the 'Color' property of the text (or other) object on top of it.


Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Richard,

The error is telling you that you're trying to modify the Color property of some object, but the object that's being modified doesn't actually have a Color property.

This usually appears when you're using one of the built-in object variables (Self, Container, Active, and so on).

You'll want to find the code that's modifying Color and review it to make certain that the object being used actually has a Color property.

For example, let's assume your code refers to Active. Here's one way to determine if Active actually has a Color property:

Code:
var
   str  String
   dyn  Dynarray[] String
endVar

   active.enumUIObjectProperties( dyn )
   if dyn.contains( "Color" ) then
      active.Color = Blue
   else
      msgStop( "Can't Set Color", "Reason: " +
               "The active object (" +
               active.Fullname + ") doesn't " +
               "have a Color property." )
   endIf

Good error checking can be very useful for this type of thing. Consider, for example, the following code (which shows how to detect specific errors and provide customized responses that offer more details than the built-in error mechanism:

Code:
   try
      active.Color = Blue
   onFail
      if errorHasErrorCode( peNoProperty ) then
         errorClear()
         msgStop( "Can't Set Color", "Reason: " +
                  "The active object (" +
                  active.Fullname + ") doesn't " +
                  "have a Color property." )
      else
         errorShow() ; other problem
      endIf
   endTry

In this case, we're replacing the default error handling mechanism with a custom error message that tells you the name of the object that triggered the error.

This is useful information. In this case, for example, you might have moved your code to a new button (for test purposes), but forgot to turn off the button's tab stop property.

Why would that be important? Well, when a button's tab stop property is true, focus moves to the button before its pushButton event is fired. Button's don't have Color properties and, viola, the error is generated.

It's not an easy subject to completely describe in a short reply, but I hope this gives you some ideas for thought.

Hope this helps...

-- Lance

P.S. These are excellent questions and you're running into things that most of us have tripped over at one point or another. With Paradox, experience is the best teacher, just so long as you're not afraid to ask for help when you need it.

P.P.S. Or to put things like my grandmother used to, the only stupid questions are the ones you don't ask. :)
 
Richard,

Oh, as a follow-up, here's how to figure out where the code is that refers to the Color property. It's in the form of a script. Also, notice that MYFORM.FSL needs to be replaced with the name of the form you're actually working with:

Code:
method run(var eventInfo Event)
var
   frm  Form
   qbe  Query
   tc   TCursor
   tv   Tableview
   str  String
endVar

   if not frm.open( ":WORK:XYZZY.FSL", winStyleMinimize ) then
      msgStop( "Can't Find Code", "Reason: Can't open the form." )
   else
      frm.enumSource( ":priv:pal$src", Yes )
      sleep()
      frm.close()

      str = "Color"

      qbe = Query

         :PRIV:PAL$SRC | Source                 |
                Check  | ~( ".." + str + ".." ) |

      endQuery

      if not qbe.executeQBE( tc ) then
         msgStop( "Can't Find Code",
                  "Use >> for details..." )
      else

         if tc.nRecords() = 0 then
            msgInfo( "Sorry", 
                     "The form doesn't contain \"" +
                     str + "\"." )
         else
            tc.instantiateView( ":priv:answer.db" )
            tc.close()
            tv.open( ":priv:answer.db" )
         endIf

      endIf
   endIf

endMethod

Now, this is crude and fails if :pRIV:pAL$SRC.DB or :pRIV:ANSWER.DB are being used bu another document.

Hope this helps...

-- Lance
 
Whoops, typo:

Also, notice that MYFORM.FSL needs to be replaced...

should be:

Also, notice that XYZZY.FSL needs to be replaced...

Sorry,

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top