Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Triggering ItemChanged Event through Script

1,186 views
Skip to first unread message

Charles Sustek

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
I need an ItemChanged event to trigger in my datawindow after a column is
changed through powerscript. How can I do this? I know about triggering
events, but I don't know how to pass this event the arguments it needs (more
specifically, the dwo argument - how do I get a reference to the column that
changed?)

Thanks,
Charles Sustek
csu...@acep.org


Anand Kumar

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Hi,
You can write the code in the itemchanged event as follows
Choose Case dwo.name
Case "salary" /* (datawindow column names) */
If Dec(data) < 0 Then
MessageBox(parent.Title,"Salary cannot be negative.")
Return 1
End If
Case "zip"
If Len(data) < 5 Then
MessageBox(parent.Title,"Zipcode cannot be less than 5
characters.")
Return 1
End If
End Choose
In the ItemError set Return 1 to avoid datawindow system message.

Thanks,
Anand Kumar
Anand Kumar
Charles Sustek <csu...@acep.org> wrote in message
news:8mTBpID8$GA....@forums.sybase.com...

Charles Sustek

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Actually, I need to trigger this event after I've changed the column via a
function from another window - basically, I need to trigger an itemchanged
event from an outside object.

Anand Kumar <kumara...@hotmail.com> wrote in message
news:#uzHZZD8$GA....@forums.sybase.com...

Anand Kumar

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Hi,
Call the acceptText() function.

Thanks,


Anand Kumar
Charles Sustek <csu...@acep.org> wrote in message

news:$XDgrhD8$GA....@forums.sybase.com...

Charles Sustek

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Here's more info:

I have a window that contains a datawindow. One column is an id, the other
is a name. The user can right click on the id column, which opens another
window allowing them to perform a search. After they've performed their
search, the new window assigns the id via the SetItem function. My
itemchanged event contains script that populates the name column based on
the value in the id column - this triggers when manually entering id's but
does not trigger when I assign a value via the SetItem function. What can I
do?

Thanks
Charles Sustek
csu...@acep.org

Anand Kumar <kumara...@hotmail.com> wrote in message

news:AmNj9iD8$GA....@forums.sybase.com...

Anand Kumar

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Hi,
Did you try using SetText function which sets the value in the edit buffer
in the itemchange event.
Eg:
This.SetItem(row,column,data)
This.SetText(data)
Return 2

Thanks,
Anand Kumar

Charles Sustek <csu...@acep.org> wrote in message

news:x7cGZnD8$GA....@forums.sybase.com...

Vladimir Gendler

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to Charles Sustek
Hi Charles,

As suggested in the one of the messages before AcceptText() will not
help. It is used when you enter data (either manually or through any kind
of Import or using SetText()) in the multiline edit which PB paints
over the edited cell. When you use SetItem() it does not go through
this sequence of events which starts from populating of the multiline
edit mentioned above - ItemChanged is one of them. Actually you
are after the successful changed data in the cell after the SetItem().
So, you have two paths to change data. One is traditional
(manual) typing and another one is from the script by using SetItem().
You need to define either a user even or function (based on your personal
preferences) to accommodate the logic which must be performed after
this item has been changed and trigger this event (or call this function)
when the changed occur.
So, you will call this event (or function) from within the ItemChanged
event and immediately after populating this item within the script.

Regards, Vladimir.

Ron Gallagher

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Charles --

Based on the additional details you've provided, here's my suggestion:

1) Add a protected method (note the scope) on the 'primary' window called
of_IdWasSet(). This method has no arguments, All that you do in this
method is set the name column based on the value of the id column. I'll
talk about where this method is called in a moment.
2) Add a public method (again, note the scope) on the 'primary' window
called of_SetId(). This method has a single argument that will contain new
value for the id. In this method, you'll set the id in the dw via the
SetIem method and then call the of_IdWasSet() method.
3) In the itemchanged event for the dw on the 'primary' window, if the user
changed the 'id' column, then post a call to of_IdWasSet().
Parent.post of_IdWasSet()
4) In the 'selection' window, when the user selects a record and you want to
set the id on the 'primary' window, just invoke the of_SetId method, passing
the new id value.

With this approach, you've hidden any 'outsiders' (i.e. the 'selection'
window) from the nitty gritty details of what happens whenever the id must
be set, and all of the logic that you perform in response to the setting of
the id column is in one location (of_IdWasSet())

HTH

Ron Gallagher, CPDP
Atlanta, GA
rongal...@mindspring.com


"Charles Sustek" <csu...@acep.org> wrote in message

news:x7cGZnD8$GA....@forums.sybase.com...

Simon Caldwell

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
You can do this as follows:

dwobject ldwo_object
long ll_row
string ls_value
ldwo_object = this.object.colname
ll_row=1
ll_value = "value"
this.Event ItemChanged(ll_row,ldwo_object,ls_value)

However, there is no generic way of getting the value for dwobject, ie you
have to hardcode the column name.

A better solution would be to move the code from item changed into a user
event, and call this user event from both itemchanged and the place where
you wish to trigger itemchanged.

HTH

Simon

0 new messages