Powerbuilder DataWindow - Preventing New Row when Tabbing Off Last Column

Posted on 2010-11-09
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 100 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 100 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.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


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 300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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ā€¦
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

808 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