PDA

View Full Version : <Browse>.HOME() works one place but not another


ABC123

malsalcnc
01-26-2015, 08:07 PM
Hi all

I think this is a scope issue or a where the focus is issue but I cant see it.

This is my code attached to events on a browse.

it does a simple check on the existence of a data Pair in a table and then what gets done with that data.

I have got the detection going and there are some choices that get made.

when i say No to adding the record I want the focus to return to the first column of the browse using


Parentform:CONTROL_BROWSE1.home()

it doesn't work straight after the no selection

but does at the end of the function which of course is the wrong place.

please tell me the obvious.


FUNCTION Product_ID_onchange as v ()

DIM GLOBAL VProd_ID AS n
dim tbl as P
dim qry as P
dim nrecs as N

VProd_ID = CONTROL_BROWSE1.Product_id.value

'ui_msg_box("On Change Event for Browse. Browse name is: ",this.name() + crlf()+ "Product ID " + VProd_ID + crlf() + "Customer ID" + VCust_ID)


tbl = table.open("cust_prod_join")
query.description = "Data_Pair_exist"
query_order = ""
query_filter = "Product_ID = VAR->VProd_ID .and. Customer_ID = VAR-> VCust_ID"
query_flags = ""
qry = tbl.query_create(query_flags, query_filter, query_order)
nrecs = qry.records_get()
IF (nrecs = 0) then
qry.drop()
responce = ui_msg_box("No Data Pair","This is a new product for this Customer. Do you want to add it?",UI_YES_NO)
if responce = UI_YES_SELECTED then
ui_msg_box("YES","YES")
elseif responce = UI_NO_SELECTED then

'ui_msg_box("NO","NO")
Parentform:CONTROL_BROWSE1.home() 'This doesnt work
end if

query.order = ""
query.filter = ""
tbl.close()

END
end if

'ui_msg_box("Data Pair Exists","This product already is made for this customer. No further action required",UI_INFORMATION_SYMBOL)

tbl.close()

Parentform:CONTROL_BROWSE1.home() 'this does work

END FUNCTION


regards

Stan Mathews
01-26-2015, 09:38 PM
You don't show where cust_id is established and dimmed and what type it is. Likely it is global but the filter should be (to expose the variables)

query_filter = "Product_ID = "+VAR->VProd_ID+" .and. Customer_ID = "+VAR-> VCust_ID

if cust_id is numeric

query_filter = "Product_ID = "+VAR->VProd_ID+" .and. Customer_ID = "+quote(VAR-> VCust_ID)

if it is character.

malsalcnc
01-27-2015, 07:25 PM
The VCust_ID is a global variable that is given a numerical value as the form opens.

Just to make sure I also set the variable in the script.

What's happening is that the first

Parentform:CONTROL_BROWSE1.home()

function is not causing the cursor/focus to go to the first column of the browse. it stays in the column that I selected.

but the second one does

Stan Mathews
01-27-2015, 07:36 PM
Maybe put parentform:control_browse1.activate() immediately prior to the .home?

Stan Mathews
01-27-2015, 09:17 PM
Don't ask me why but

replace the

Parentform:CONTROL_BROWSE1.home()

with (both lines)

sys_send_keys("{home}")
sys_send_keys("{home}")

malsalcnc
01-28-2015, 02:53 PM
Thanks for that. wood for trees stuff.

Stan Mathews
01-28-2015, 03:19 PM
Seems to me that Parentform:CONTROL_BROWSE1.home() should work but I don't keep after something very long if I can find an alternative.

malsalcnc
01-28-2015, 08:33 PM
The tricky thing is knowing what those alternatives are. And I like to think that I have done some good research before asking the questions I do.

one day it may be my turn to contribute as well as being helped.