Go Premium for a chance to win a PS4. Enter to Win


Powerbuilder DataWindow - Preventing New Row when Tabbing Off Last Column

Posted on 2010-11-09
Medium Priority
Last Modified: 2013-12-26
Hi All,

I would be grateful for suggestions on the following scenario.

We have a dynamically created datawindow, which is used as a data entry form.
We only ever want one row in this datawindow, but each time the user tabs off
the last last column on the datawindow a new row is created. Without having to
use the DeleteRow function, is there any way of preventing the new row being created
when the user tabs off the last column? I can trap the Tab key press using event id, pbm_dwnkey, but as far as I can see Powerbuilder has already generated the row by the time the script associated with pbm_dwnkey runs. I think I'm really looking for a way to prevent Powerbuilder creating a new row, when one exists already.



Question by:cintra

Assisted Solution

stanner earned 400 total points
ID: 34094480
Are you sure you don't have anything in your datawindow to "cause" it to jump to a new record? By default, PowerBuilder does not insert a new record when you tab off the last field. Focus either jumps to the next object on the window, or back to the first column on the same row in the datawindow. You actually have to "make" it insert a new row. I just tried it again now to confirm, in case I was losing my mind. If you already have multiple rows in the datawindow, THEN it will jump to the next record, but it won't actually create one by default (unless something has changed). Is there any chance you already generated more than one empty row, and it's just jumping to one of those?

Author Comment

ID: 34094768
Thanks for the response. I'm fairly certain there is only one InsertRow occurring, but I will double check.
LVL 14

Assisted Solution

sandeep_patel earned 400 total points
ID: 34137786
Are you using PFC? or check there is any code written in itemchanged or losefocus events. Such coding should have been done mostly in acenstor objects. Check object hierarchy and see if code is written in above events to insert a row.

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 34147207
Hi Again,

Thanks for the comments above. I am not using PFC, but I notice that the behaviour of a dataobject created as freeform is different from a dataobject
created as tabular. When the freeform datawindow is placed on a window, tabbing off the last column does not create a new row, but if the tabular datawindow is used on the window, tabbing off does indeed generate a new row. I think my dynamically created datawindow may be getting created as a tabular datawindow, even though it's only ever supposed to hold one row. I will do further checking and revisit the question to assign points to all who responded.



Accepted Solution

Ariel Garcia earned 1200 total points
ID: 37442833
I resolve this:
On Event "RowFocusChanging" write this...

If RowCount() = 1 Then
    Return 1
End if

Occurs when the current row is about to change in the DataWindow. (The current row of the DataWindow is not necessarily the same as the current row in the database.)

Return Value:
Set the return code to affect the outcome of the event:
0  Continue processing (setting the current row)
1  Prevent the current row from changing


Author Comment

ID: 37445525
Thanks for this leirags.

I think that could be the solution.
I will do some testing and report back.



Author Comment

ID: 37492820
Hi all,

I can't replicate the beheaviour I originally described with a "normal" datawindow, but only with one that is dynamically created at run time. In any case, I have discovered a work around, based on the suggestion from leirags.

I will distribute poinst to all who responded.



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question