INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

SetItem for Computed Field on DW - Not Working?

SetItem for Computed Field on DW - Not Working?

(OP)
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

RE: SetItem for Computed Field on DW - Not Working?

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

RE: SetItem for Computed Field on DW - Not Working?

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

Do you have any other ideas?

Keith

RE: SetItem for Computed Field on DW - Not Working?

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.

RE: SetItem for Computed Field on DW - Not Working?

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close