Alpha DevCon 2018
Results 1 to 7 of 7

Thread: Value checking in embedded browse

  1. #1
    Member
    Real Name
    gfong
    Join Date
    Jan 2001
    Location
    Dartmouth, Nova Scotia, Canada
    Posts
    369

    Default Value checking in embedded browse

    I have a browse on a form based on my invoice_detail table which contains three fields: Qty_ordered, Delivered, Billing_qty. I am trying to find a way to ensure that the user is unable to enter a billing_qty greater than Qty_ordered-Delivered. I have written a script for the ondepart event for Billing_qty to handle this on another form but the user would have to pop up the form each time he wants to enter a Billing_qty. I am trying to do this with a browse where all the info for all the rows is available at a glance. My problem is that although I can change the properties for the column there are no actions I can associate with the field column. I just want a ui_msg_box to pop up when the user enters the wrong quantity.

  2. #2
    Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,501

    Default RE: Value checking in embedded browse

    I was trying to do something simlar the other day - don't know if it is doable. Perhaps a work-around is to place the fields on the form (you can hide them) and address the field objects instead of the browse. The fields will display (or contain - as the case me be) the current record that the browse is pointing to.

  3. #3
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,894

    Default RE: Value checking in embedded browse

    here's a way:
    go to the field rules for the table, and enter scripts as needed:

    following are three scripts, each for use on a different form, where the table is in an embedded browse on the form, all for the same table, of course, at the onwrotefield event:
    '******************
    'do different things for different forms
    if is_object(":batteries")
    tbl=table.get("batteries")
    tbl.amount=tbl.quantity * tbl.amt_each
    :batteries:browse1.refresh()
    :batteries:browse1.commit()
    end if
    if is_object(":tbatteries")
    tbl=table.get("batteries")
    tbl.amount=tbl.quantity * tbl.amt_each
    :tbatteries:browse1.refresh()
    :tbatteries:browse1.commit()
    :tbatteries:button2.activate()
    end if
    if is_object(":batteries3")
    tbl=table.get("batteries")
    tbl.amount=tbl.quantity * tbl.amt_each
    :batteries3:browse1.refresh()
    end if

    '***********
    and here is a script that fires at the cansaverecord event for the table:
    'set default price based on company

    if is_object(":edit batteries")
    t=table.get("batteries")
    if rtrim(var->company)="HAE"
    t.amt_each=t.hae
    elseif rtrim(var->company)="IHS"
    t.amt_each=t.ihs
    end if
    :edit_batteries:browse1.refresh()
    end if

    also, you can do a lot on the form's browse's canrowchange event

    although this code does't directly reflect your need - I think you can get the idea

  4. #4
    Member
    Real Name
    gfong
    Join Date
    Jan 2001
    Location
    Dartmouth, Nova Scotia, Canada
    Posts
    369

    Default RE: Value checking in embedded browse

    I just stumbled on the CanRowChange event of my embedded browse and I think I've managed to get something to work:

    t=table.current()
    IF t.qty_ordered-t.delivered

  5. #5
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,894

    Default RE: Value checking in embedded browse

    greg, although your situation may be different, I would think the billed quantity would always be the same as the delivered quantity.
    t.billed_qty=t.delivered_qty

    just change your script:

    t=table.current() 'as stated, you are here addressing the primary table in your set, if the form is based on a set.
    t=table.current() 'top table
    t=table.current(1) 'top table
    t=table.current(2) '1st child
    if the browse is based on a child, then be sure the current() is correct


    IF t.billed > t.delivered
    ui_msg_box("Warning","Billing Quantity Too High")
    browse1:billing_qty.activate()
    cancel()
    end if

  6. #6
    Member
    Real Name
    gfong
    Join Date
    Jan 2001
    Location
    Dartmouth, Nova Scotia, Canada
    Posts
    369

    Default RE: Value checking in embedded browse

    Thanks for being thoughtful enough to consider issues beyond the question that I posed. This is the wonderful magic of this board.
    The invoicing portion of my app makes use of a sales order set and an invoicing set. The sales order set holds the original order. In many cases the company does not hold any inventory and there are times when only partial orders can be shipped out. The company only invoices for items shipped. As items are shipped out, partial invoices are produced. That is why billed quantities can be less than delivered quantities. The user can at any time review the status of an order by refering to the sales order set. There he can see what was originally ordered and what has been delivered to date. By examining the invoice set he can see the effect of each individual billing and the quantities associated with each billing. I hope this makes sense?

    Thanks once again.

  7. #7
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,894

    Default RE: Value checking in embedded browse

    yes - that makes sense

    in your canrowchange script, I should have suggested,

    t=table.current(correctreferencenumberhere)
    if t.billed_qty t.delivered_qty
    ui_msg_box("Warning","message")
    cancel()
    end
    end if

    one potential issue here is the mode of the table. if they are just scrolling the browse, you will get an error message. because we are using table methods to set the tables value.

    so, add,
    t=table.current(correctreferencenumberhere)
    if t.mode_get()=0
    t.change_begin()
    end if
    if t.billed_qty t.delivered_qty
    ui_msg_box("Warning","message")
    cancel()
    end
    end if
    'i don't usually put a change_end() here because the from commits the record when the row changes

    you could also use form methods, instead of table methods -
    if browse1:qty_billed.value > browse1:qty_delivered.value

    the advantage of form methods is you don't have to worry about whether they are in a view, change, and/or enter state.

    I have spent hundreds of hours experimenting with ways to successfully control entry/change in embedded browses. And I tend to use table field rules most of the time. It seems to work better.

    But for often inexplicable reasons, one method works better in one instance than the other.

    I'll see if I can put together a small sample of my database where I tightly control the users in embedded browses.

Similar Threads

  1. EMBEDDED BROWSE
    By aaron nash in forum Alpha Five Version 5
    Replies: 4
    Last Post: 05-19-2003, 01:36 PM
  2. Embedded Browse
    By Danny Marx in forum Alpha Five Version 5
    Replies: 1
    Last Post: 12-26-2002, 12:28 AM
  3. Embedded Browse
    By Bruce MacPherson in forum Alpha Five Version 4
    Replies: 3
    Last Post: 12-17-2001, 02:48 PM
  4. Embedded Browse
    By James Peterson in forum Alpha Five Version 4
    Replies: 6
    Last Post: 07-26-2001, 10:08 PM
  5. Embedded Browse
    By WillieLucas in forum Alpha Five Version 4
    Replies: 1
    Last Post: 05-10-2000, 04:44 PM

Posting Permissions

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