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!

SetItem for Computed Field on DW - Not Working?

Status
Not open for further replies.

kaul125

Programmer
Jan 29, 2002
87
US
I want to be able to set a value for a computed field on my datawindow through a script in the window. I have to check to see if specific columns( about 15 in the dw) are equal to a certain value. If it is, I want to set the computed field to a certain value. The reason I don't want to do this in the computed object expression box in the dwo, is because I have 15 fields to check. This would be a combersome if statement.

How come the setitem for the computed field is not working? Can I do a setitem on a computed field? And, if so, what is the correct syntax?

keith
 
Keith,

You should be able to use the same syntax for the computed field that you would for any other field in the datawindow.

dw_1.SetItem(ll_row, column_name or column_number, ls_value)

ll_row = the number of the row in the datawindow you want to set the value for

column_name = name of the computed field. It will be compute_1 if you have not changed the name of it to match the data.

column_number = equals the number of the column you want to set. This is determined by where it is in the select statement. So you should use column_name in this case with a computed field

ls_value = value you want to set the field to.(Does not have to be a string)

If that doesn't work on it's own, try doing an AcceptText after you do your set item and see if that fixes the problem.

Dan
 
Thanks, I tried your suggestion, AcceptText, after the setitem, but it still does not except the value.

Do you have any other ideas?

Keith
 
I think the PB documentation is incorrect as it implies you can do a setitem on a computed field. I think you are going to have to change to a computed column (which is different) to use the setitem method.
 
mbalent:

What is the difference between a computed field and a computed column? How do I create a computed column?

When I talk about a computed field, I just put a computed object on the datawindow from the datawindow painter.

When I debug the following code, it returns a -1:
li_rtnval = dw_1.SetItem(1,"c_computed_field","X")

Does a -1 one mean it is an invalid column? I've doubled checked to make sure I have the correct name and it is.

How can I solve this problem?

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top