To further refine an external function.

Posted on 2006-05-30
Last Modified: 2013-12-26

The exported version of the function is

$PBExportComments$Checks that all required columns in a DataWindow control are filled in
global type f_checkrequired2 from function_object
end type

forward prototypes
global function boolean f_checkrequired2 (datawindow adw_control)
end prototypes

global function boolean f_checkrequired2 (datawindow adw_control);integer li_colnbr = 1
long ll_row = 1
string ls_colname, ls_textname

IF adw_control.AcceptText() = -1 THEN
      RETURN false

IF adw_control.FindRequired( primary!, ll_row, li_colnbr, ls_colname, false ) < 1 THEN
      RETURN false

IF ll_row <> 0 THEN

      // Get the text of that column's label.

      ls_textname = ls_colname + "_t.Text"
      ls_colname = adw_control.Describe(ls_textname)

      // Tell the user which column to fill in.

      Beep (1)

      MessageBox("Required Value Missing","Please enter a value for '" + ls_colname , exclamation!)

      // Make the problem column current.

      RETURN false


end function

The above function works well for all physical columns of a  datawindow.

What do I mean by non physical column

Suppose I have made a drop down datawindow "dddw_x" with this sql select
"select colour_code, colour_name from colour"

The actual datawindow say dw_trans only have column colour_code. ( It does not have column colour_name)
What I do Is , I copy the column colour_code and rename the copied column as 'colour_name', then I associate the drop down datawindow "dddw_x" on that column. Hence

colour_code is physical
colour_name is virtual

When the above function is run , colour_code and colour_name both being null, (on both required option is on), the function will detect that colour code is required , and set the focus on column code, so that the user can enter any value.

The problem is, it is easier to enter value via colour_name , but the function will not let go to colour_name untill colour_code is filled.

What I want is, that , in such case , the user should be able to fill value by colour name also.


Question by:Mateen
    LVL 18

    Expert Comment


    what u can do is in open event have the following script...
    dw_1.Object.color_code.Edit.Required = "no"

    and just  before u call ur function to check for required values write,
    dw_1.Object.color_code.Edit.Required = "yes"

    so what will happen is it will b treated as a required field when the function fires and prompt if found null...

    LVL 14

    Expert Comment


    why you need column color_name ?
    what happens here is both physical and virtual column name is different but their dbname is same. So there is no meaning of copying the column and renaming it. Still if you want column color_name and color_code in your datawindow, go to sql and add computed column or you can change your sql like

    select  trans_no , tran_date, color_code as color_code, color_code as color_name from transaction_detail ;

    in your dw_trans sql syntax.


    Author Comment

    Hi sandeep

    <<there is no meaning of copying the column and renaming it.>>

    But I am doing this in hundreds of windows for displaying child datawindow.  I think I should say child datawindow and should not say drop down data window.


    Author Comment

    Hi diaroshan

    <<dw_1.Object.color_code.Edit.Required = "yes">>

    I want things to be dynamic.

    Do u rember

    That was a great achievement.

    I feel, this is similar a case.
    LVL 18

    Expert Comment


    guess u cant do this dynamically... ull have to write code in each window coz there is no way to ascertain which column u want to ignore and then validate later...


    Author Comment

    <<guess u cant do this dynamically... ull have to write code in each window coz there is no way to ascertain which column u want to ignore and then validate later...>>


    Could we go for a workaround.

    1) Findrequired should work as u suggest.
    2) Before running findrequired function , I can run, for validation purpose, another user defined function, say

     wf_check_null_child_dw: Is it possible to create a function which would find all child datawindow in a datawindow control. IN OUR CASE, it could be made simple by finding a column name whoose dbname differs. etc.
    LVL 18

    Accepted Solution


    mateen... uve got the idea urself... :)
    i am not creating a function for u but giving a basic code which might give u help to try this urself...

    create a function... u can pass DW to it and loop thru it to search which column is a DDDW and check if its column name differs from the dbname...
    u can use the code below... just written it here... DIDNT TEST IT MYSELF... use it as a help for u...

    Long     ll_count
    string   ls_style,ls_colname, ls_colname2

    //dw_1 is ur passed value to the function
    For ll_count = 1 to Long(dw_1.object.datawindow.column.count)
         ls_style = dw_1.describe('#'+string(ll_count)+"")
         if ls_style = 'dddw' then
          ls_colname  =  dw_1.Describe('#'+string(ll_count)+".name")
          ls_colname2=  dw_1.Describe(ls_colname + ".dbName")
          point_position = pos(ls_colname2,'.')
          ls_colname=mid(ls_colname2,point_position+1) //coz dbname will b with table name

          If ls_colname <> ls_colname2 Then
                        //write ur logic here...
          End If
         End If      


    Author Comment


    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    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…
    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now