Back

Tip 17. Informing the User when No Rows are Retrieved.

Normally when a datawindow or report is retrieved and there are no rows you are presented with a blank datawindow. This can be confusing for users especially if the need to insert a row. To get around this we have added a piece of text to the blank datawindow informing the user that there are no rows.
This text is made visible if there is no rows and invisible if there are rows. The resize event is used to keep the text central.

To achieve this you must first create a user object based on a datawindow.

In the constructor event create the datawindow text control

//---------------------------------------------------------------------------
//  Event Name : constructor for ua_dw_std
//     Purpose : Add no rows text
//        Sets : None
//---------------------------------------------------------------------------
string ls_modify_string
string ls_error_string
long   ll_x, ll_y

ll_x = (this.width - 357 )/ 2
ll_y = (this.height - 57 )/ 2
ls_modify_string = 'create text(band=foreground alignment="0" ' &
    + 'text="No Rows Found" border="0" color="0" ' &
    + 'x="' + String(ll_x) + '" y="' + String(ll_y) + '" ' &
    + 'height="57" width="357" name=no_rows_found ' &
    + 'font.face="Arial" font.height="-8" font.weight="400" ' &
    + 'font.family="2" font.pitch="2" font.charset="0" ' &
    + 'background.mode="1" background.color="553648127" ' &
    + 'visible="1~tIF(RowCount()=0,1,0)")'
ls_error_string = Modify(ls_modify_string)
In the resize event keep the text control central to the datawindow.

//---------------------------------------------------------------------------
//  Event Name : resize for ua_dw_std
//     Purpose : move no rows text
//        Sets : None
//---------------------------------------------------------------------------
long ll_x, ll_y
ll_x = (this.width - 357 )/ 2
ll_y = (this.height - 57 )/ 2
this.Modify('no_rows_found.X="' + String(ll_x) &
    + '" no_rows_found.Y="' + String(ll_y) + '"')

Added before 01 Jan 2000

Back