Newbie Checkbox Question for Powerbuilder 6.5

Posted on 2005-04-08
Last Modified: 2013-12-26
Ok, I know little to nothing about Powerbuilder, however I have a small task to complete in a PB app that my company uses. The task is very simple and is this.
I have a window that contains 3 separate datawindows. In one of the datawindows "dw_builder_det" I want to add a checkbox. This checkbox is just a yes or no.  The SQL database field that in connects to is called '"moisturesmart_yn". The feild has a default setting of "N". So all builders in this table default to "No" What I want to do is when the user goings into the above window and checks the box it changes the the default value from "N" to "Y". But what I want also is that on checking the box a message is displayed to the user asking them if they're sure they want to proceed with the change. I 'd also like to do the reverse. Once its been changed to "Y" and they remove the check mark, the user is prompted again and the change is reflect in the database. Thats it. Thanks  
Question by:Duec
    LVL 18

    Accepted Solution


    to make the field moisturesmart_yn a check box u need to go to the database painter of the DW first..
    next u need to select the field moisturesmart_yn and go to its properties Edit--->Style Type and select checkbox there....
    there u can enter the value for 'data value for On' to 'Y'(without the quotes) and value for 'data value for Off' to 'N'....

    now to make 'N' the default...
    Goto the menu View--->Column Specification

    the column specification appears below...
    goto the field moisturesmart_yn and make its 'initial value' 'N'(without the quotes)

    now for the message Boxes...
    goto the item changed event of the DW....
    in there write the script...

    String ls_yn
    If = 'moisturesmart_yn' Then
    If ls_yn = 'Y' Then
    MessageBox('Information','Are you sure you want to set moisturesmart to YES' )
    MessageBox('Information','Are you sure you want to set moisturesmart to NO' )
    End If
    End If

    That shud sort out ur queries...
    Do ask if u need more assistance...

    LVL 8

    Expert Comment

    to make the filed to checkbox

    step 1 go to the properties of the field and under edit selecet checkbox from style type.
    step 2 click on 3d look

    step 3  enter Y for datavalue on and N for data value OFF

    step 4 now gor for the itemchanged event for that window by rightclick/script
    and enter the folling code

    String lsy
    long l_answer
    If = 'moisturesmart_yn' Then
    If lsy = 'Y' Then
        l_answer= MessageBox('Information','Are you sure you want to set YES',StopSign!,YesNo!,2 )
        if l_answer=2 then
           return 1
        End if
    End If

    If lsy = 'N' Then
        l_answer= MessageBox('Information','Are you sure you want to  No',StopSign!,YesNo!,1 )
        if l_answer=1 then
           return 1
        End if
    End If

    if you require more information just let give a shout

    Author Comment

    Thanks a lot, both answers work fine, I awarded the points to  diasroshan as it was the first answer that I tried and worked. I do have another question how ever reagarding this same job hpwever I willl post it separatley.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    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…
    Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now