Alpha Video Training
Results 1 to 8 of 8

Thread: <Browse>.HOME() works one place but not another

  1. #1
    Member
    Real Name
    Malcolm Salisbury
    Join Date
    Nov 2013
    Location
    Christchurch, New Zealand
    Posts
    25

    Default <Browse>.HOME() works one place but not another

    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.

    Code:
    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
    Why did I ever say yes?

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: <Browse>.HOME() works one place but not another

    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.
    There can be only one.

  3. #3
    Member
    Real Name
    Malcolm Salisbury
    Join Date
    Nov 2013
    Location
    Christchurch, New Zealand
    Posts
    25

    Default Re: <Browse>.HOME() works one place but not another

    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
    Why did I ever say yes?

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: <Browse>.HOME() works one place but not another

    Maybe put parentform:control_browse1.activate() immediately prior to the .home?
    There can be only one.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: <Browse>.HOME() works one place but not another

    Don't ask me why but

    replace the

    Parentform:CONTROL_BROWSE1.home()

    with (both lines)

    sys_send_keys("{home}")
    sys_send_keys("{home}")
    There can be only one.

  6. #6
    Member
    Real Name
    Malcolm Salisbury
    Join Date
    Nov 2013
    Location
    Christchurch, New Zealand
    Posts
    25

    Default Re: <Browse>.HOME() works one place but not another

    Thanks for that. wood for trees stuff.
    Why did I ever say yes?

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: <Browse>.HOME() works one place but not another

    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.
    There can be only one.

  8. #8
    Member
    Real Name
    Malcolm Salisbury
    Join Date
    Nov 2013
    Location
    Christchurch, New Zealand
    Posts
    25

    Default Re: <Browse>.HOME() works one place but not another

    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.
    Why did I ever say yes?

Similar Threads

  1. Place a summary field below an embedded browse?
    By Robert Bunt in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 11-24-2008, 10:08 PM
  2. Browse - place <New Record> on top?
    By Steve Wood in forum Alpha Five Version 9 - Desktop Applications
    Replies: 6
    Last Post: 06-14-2008, 08:57 PM
  3. Place cursor in browse column
    By Steve Workings in forum Alpha Five Version 9 - Desktop Applications
    Replies: 6
    Last Post: 06-04-2008, 11:10 AM
  4. Where to place the browse refresh command
    By georgefurnel in forum Alpha Five Version 8
    Replies: 2
    Last Post: 11-02-2007, 11:10 AM
  5. Unable to place a column title on embedded browse
    By Beltronics in forum Alpha Five Version 8
    Replies: 40
    Last Post: 10-29-2007, 12:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •