Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving DW with referece to checkbox and SLE 2

Status
Not open for further replies.

jhonesmale

Technical User
Mar 16, 2009
5
NO
Hello,

I am new in using the Powerbuilder. I need some answers for the tool that I am bulding for reports retrieval.

I have a window with the following details:
1. 3 checkbox with SLE beside them.
2. 1 datawindow
3. 1 command button named retrieve

The 3 checkbox with SLE indicated criteria on how i want to view the report. The report will be coming from 4 diff tables.
1st is by name
2nd is by number
3rd is by date

What I want to do is when I click on the retrieve button, I will get the reports depending on which checkbox is TRUE and whatever I put on the SLE. I want to see this report on the DW.

Please help me through this simple requirements that I have.

Thanks and brgds,

jhon
 
I don't know if I understand your question.
First of all is a SELECT statement for DataWindow. There is no matter how many tables you want to use. Prepare Select statement and paste it into DW.
Could you explain what does it mean:
"The 3 checkbox with SLE indicated criteria on how i want to view the report. The report will be coming from 4 diff tables.
1st is by name
2nd is by number
3rd is by date"?

IF retrieved data depends on values of Checkboxes and sle you cat put them as retrieval arguments. In that case go to DataSource of your DW. Next go to menu: Design > Retrieval arguments and define them. Next put your cbxs and sle values to dw.Retrieve() method.

If it isn't clear for you feel fre to ask.
Tomek
 
Hi Mariaszek,

Thank you for your reply.

I have define the retrieval arguments. My problem is that when I am running the application, the Retrieval Argument dialogbox is the one popping out instead of me putting values on the SLE. and even i put values on the SLE and then press the Retrive button, the Retrieval Argument dialogbox apprears again.

Please send me the proper dw.Retreive script for this so that I only have to put values on the SLE and then when I click on the retrieve button, I will get the datas that i need.

Thanks again,

Jhon
 
The problem is that you should put proper values as arguments of Retrieve() method.
It works like this:
1. If you don't define retrieval arguments in DataSource of your DW, you simply call dw_1.Retrieve().

2. If you define retr. arguments you should pass values for retrieve or there dialogbox appears.

I try to write example code for you. In my example there are 4 retrieval arguments defined in DataWindow (ai_one number, ai_two number, ai_three number, as_four string). So, during retrieval data DW will expect four arguments.


Sample srcipt:
// cbx_one, cbx_two and cbx_three are Checkboxes on your
// screen and sle_four is your SingleLineEdit
// dw_data is name of your DataWindow to show retrieved data
Integer li_cbx1, li_cbx2, li_cbx3

IF cbx_one.Checked THEN
li_cbx1 = 1
ELSE
li_cbx1 = 0
END IF

IF cbx_two.Checked THEN
li_cbx2 = 1
ELSE
li_cbx2 = 0
END IF

IF cbx_three.Checked THEN
li_cbx3 = 1
ELSE
li_cbx3 = 0
END IF

dw_data.Retrieve(li_cbx1,li_cbx2, li_cbx3, sle_four.Text)
// If sle_four.Text is NULL your popup argument
// dialogbox will show again.


 
Hello,

tried this again but i have data window error: "retrieve argument 1 does not match expected type"

what am i doing wrong?

Jhon
 
Type of arguments defined in DataObject must be the same as type of variables passed to Retrieve() function.

Look at the example I send you in previous message. In DataObject there are 4 arguments:
1st is number,
2nd is number,
3rd is number
and 4th is string.
So values passed to Retrieve() method are:
1st - li_cbx1 type integer(number),
2nd - li_cbx2 type integer(number),
3rd - li_cbx3 type integer(number),
4th - sle_four.Text type string.

If you define first argument as number (in DataObject) and the first value passed to Retrieve() method is string type you'll get message: "retrieve argument does not match expected type"

Tomek
 
Hi Tomek,

Thank your for helping me, I am still getting error so i hope you still have time to assist me. I will give you more detailed info of my window.

I have cbx_name with sle_name beside it.
I have cbx_no with sle_no beside it.
I have command button names retrieved
I have datawindow
I have 2 data source: first for the arguments of name :name
the second has the argument number :no

When I click on cbx_name the cbx_no and sle_no became disabled. this works the other way around when i check on the cbx_no. all is ok till here.

What i want to happen now, is that, when i check on cbx_name and write a name on the sle_name beside it, when i click on the retieve button, it will show the results on the data window.
Otherwise, when i check on the cbx_no and write a number on the sle_no, when i click on the retrieve button, it will show the result on the DW.

thank you again for your help.

Jhon
 
Everything is clear for me now.

First of all I suggest to use radiobutton instead of checkboxes. User can check either name or number.

There are a lot of possibilities to do that.

In your case you should:
1. Choosing data by number
datawindow.DataObject = "d_no"
where d_no is name of dataobject with number parameter.

datawindow.Retrieve(Long(sle_no.Text))
good practice is to check is sle_no.text a number or not

2. Choosing data by name
datawindow.DataObject = "d_name"
where d_name is name of dataobject with string parameter.

datawindow.Retrieve(sle_name.Text)

Tomek
 
OK, the error is simple... The datawindow is expecting two retrieval arguments for EVERY .Retrieve() call.

In the script, you will have to call it with something like dw_example.Retrieve( ls_name, ll_number )

Now, onward to you SQL statement... In the WHERE clause, you will need something like:

WHERE ( REF_NAME = :as_name OR :as_name = '' ) AND
( REF_NUMBER = :an_no OR :an_no = -1 )

To retrieve by number, pass in an empty string. To retrieve by name, pass in -1.
 
Hello Tomek and theklown,

Thank you very much for your assistance.

It is now working as I wanted it. Your assistance is a big help.

thank you also for this wonderful site.

Jhon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top