Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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 from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

SetItem for Computed Field on DW - Not Working?

kaul125 (Programmer) (OP)
22 Jul 02 11:54
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
daniel32 (Programmer)
23 Jul 02 8:41
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
kaul125 (Programmer) (OP)
24 Jul 02 0:17
Thanks, I tried your suggestion, AcceptText, after the setitem, but it still does not except the value.

Do you have any other ideas?

Keith
mbalent (Programmer)
24 Jul 02 12:20
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.
kaul125 (Programmer) (OP)
29 Jul 02 17:05
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

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!

Back To Forum

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