Alpha Video Training
Results 1 to 9 of 9

Thread: ew grandchild records for parent

  1. #1
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default ew grandchild records for parent

    i have 3 table

    parent - casefile
    child

  2. #2
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default Re: ew grandchild records for parent

    ill start again

    parent - casefile
    child - products
    grandchild - commissions (there can be multiple commission activity for each product)

    the issue i am having is to view all commission records at parent level, everything else is fine in terms of adding grandchild records, viewing grandchild records at child level.

    At parent level, my browse is showing grandchild records but only for one child record at a time.

    i have tried all sorts, basing the form on different sets, just on the commissions table only.

    i had thought of adding a field to capture the id for the parent table and then filter based upon his, but i do not see how to pss the value from the parent table to the grandchild table. (the companion form is passing the value from the child table of course)

    i have spent about 6 hours on this and now it is time to concede to the power fo the message board.

    thanks

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: ew grandchild records for parent

    the issue i am having is to view all commission records at parent level, everything else is fine in terms of adding grandchild records, viewing grandchild records at child level.
    Huh?

    A detailed example of what you're trying to achieve will help us help you. Give us an example of a case, with products and commissions. Then show us how you want it to appear when "all commission records are at parent level".

    -- tom

  4. #4
    Member mariusm's Avatar
    Real Name
    Marius M.
    Join Date
    Sep 2006
    Location
    Plymouth, UK
    Posts
    199

    Default Re: ew grandchild records for parent

    If I understand correctly, you designed the set to cascade changes from parent to child and from child to grandchild, and you're now trying to make changes in the parent that will cascade through the child to the grandchild. Right?

    I may be completely wrong on this, but in my experience cascading changes typically leads to problems - particularly if you go through more than one level of cascading.
    I always design things so a change in the child table has to be done in a form that is directly linked to the table, and cascade changes the other way, child to parent. So the parent is importing data from the child tables, not exporting data to them. Normally, I do this with forms that open in popup windows.

    Others may have a much better view on things, though.
    It is easier to get older than wiser

  5. #5
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default Re: ew grandchild records for parent

    A bit more info...

    no cascading changes, say i have a parent record for a customer and have added 2 products (child records).

    for these 2 products i have 2 grandchild records each, so a total of 4 grandchild records for the parent record.

    all i want to do is to be able to view all 4 grandchild records at the same time for the parent record.

    attached sample, login administrator - password = manager

    open form - fCaProdsEdit

    there is a browse for the child records products.
    there are 2 buttons.

    1. a small calculator in the corner of the browse. this is to add a commission to a child record (product)
    2. a larger button above titled 'view case comms' - this is to view all commissions (grandchild records) for each case (parent record)

    this is where my problem lies. i cant seem to view all grandchild records at the same time. this is to allow users to see all commission activity per customer not just per product sold.

    i hope this makes a little more sense.

  6. #6
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: ew grandchild records for parent

    Richard, yes, that makes much more sense. Unfortunately, I don't think you can do it in the same form you're describing. The set structure is wrong. Your grandchild table structure probably does not include a field that uniquely links to the parent table. Were such a field present you could use a new set in which the grandchild table is linked (as child) directly to the parent table. Using a form based on this new set you could step through the parent table records, and for each you would be able to see all the commissions records. In short, using the present set structure commissions are not linked to cases, so you can only see those commissions that are linked to products.

  7. #7
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default Re: ew grandchild records for parent

    Thanks Tom,

    I had added a field to the grandchild table to accept the value of the linking field from the parent table to allow me to do as you explain.

    however i saw no way to pass the value from the parent table to the grandchild table.

    i was thinking that maybe i needed to base a form on a set which included all 3 tables. this would allow the value from the parent table to be available to the grandhild table. but i couldnt accomplish this either.

    ill keep plugging away, but if any ideas or solutions are out there, id be glad to hear them.

    thanks

  8. #8
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: ew grandchild records for parent

    Richard, (and Tom)

    There is a new function, for v8 (although it still hasn't made it into the documentation) for opening forms called form.viewlinked(). I will include the blurb from the 'Whats New in V8' page

    Form.ViewLinked() Method - This new method is similar to the .ViewQueried() method in that it opens a form showing selected records. However, with the .ViewLinked() method, you can specify how the target form (i.e. the form that is opened by this method) is linked to a parent table, and Alpha Five will automatically ensure that the correct values are entered into the linking fields when a record is edited or created, ensuring that the records edited/created in the target form remain properly linked to their 'parent' record.

    P formPointer = Form.ViewLinked (C LayoutName , C LinkDefinition [, C filter_expn [, C order_expn [, C style [, C x_position [, C y_position [, OtherOptions ]]]]]])
    OtherOptions.Restrict_Navigation = .f.

    Where:
    formPointer A pointer to the form that is opened.
    LayoutName The name of the form to open. This is called the 'target' form. LinkDefinition A CR-LF delimited list of link conditions in the form of: linkTableField = linkValue

    e.g.
    firstname = "john"
    lastname = "smith"
    Filter_expn An optional filter to apply (in addition to the filter implied by the LinkDefinition) when the target form is opened. For example using the sample LinkDefinition shown above, the target form is automatically filtered using
    firstname = "john" .and. lastname = "smith"

    If you only wanted to see records for John Smith where the transaction date was in January, you might specify a filter_expn of:
    month(transactionDate) = 1
    Order_expn An optional order expression. Style The style in which the target form should be opened. Options are: null - open as a regular modeless form, 'dialog' - open as a modal form, 'dialog_newrecord' - open as a modal form showing a new record, 'hidden' - hidden until the .show() method is called on the form pointer, 'hidden-dialog' - hidden until the .show() method is executed on form pointer (or some other method that causes the form to become visible, such as .new_record() is called). Default value is null. X_Position Left, Center, Right, Fill or an absolute position expressed in pixels. Default value is null, which uses the definition stored in the form layout. Y_Position Top, Center, Bottom, Fill, or an absolute position expressed in pixels. Default value is null, which uses the definition stored in the form layout. OtherOptions A dot variable. Currently supports a single property. OtherOptions.Restrict_Navigation. Indicates if navigation from record to record is allowed when the target form is opened. Typically, when the user is viewing the last record in a query and he/she navigates to the 'next' record, Alpha Five displays a new record. If you want to prevent the user from navigating to a new record, set this property to .t.

    Example:
    The following command opens the 'InvoiceItems' form and ensures that any records either edited or added are automatically linked to the correct parent record (which has an InvoiceNumber of 'INV1234'). Assume for demonstration purposes that the InvoiceNumber field in the target table (i.e. the table on which the target form is based) is called 'InvNum' (and not 'InvoiceNumber' as it might be called in the parent record).

    dim LinkDef as c
    LinkDef = "InvNum = \"INV1234\""
    dim p as p
    p = Form.ViewLinked("InvoiceItems",LinkDef)
    Considering that you now have a case ref field in the commision table
    with this you could do some thing like the following in a button on your form.
    Code:
    tbl = table.current()
    'get the case id from the parent
    caseref = tbl.case_id  ' sub in your field name for the parent table case id field
    'open the commision form forcing a link using the parent case Id value
    frm = form.ViewLinked("YourCommTable","case_Id="+quote(caseref),"","")   ' case_Id here is the field in the commision table
    The form opened in this manner will always force, wether new record or editing, the case id to be the value of the linking value.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  9. #9
    "Certified" Alphaholic richard2007's Avatar
    Real Name
    Richard Harris
    Join Date
    Sep 2007
    Location
    Ashford, Kent, UK
    Posts
    1,096

    Default Re: ew grandchild records for parent

    Tim,

    thanks so much.

    i achieved this quite easily in access with this code entered into a forms 'before insert' event, and all i did was have the parent form open in hidden mode to allow the value to be passed.

    the code was very much as this

    With Forms![product tbl]
    If Not IsNull(!productid) Then
    Me.productid = !productid
    End If
    End With

    i just couldnt see a way to include the case ref in alpha5

    ill give this a go tonight.

    thanks again.

Similar Threads

  1. Can't add new child records because parent grid has no records
    By andi in forum Application Server Version 8
    Replies: 9
    Last Post: 07-11-2007, 04:19 AM
  2. Grandchild records not displaying...Help please
    By P Sabourn in forum Alpha Five Version 6
    Replies: 13
    Last Post: 11-29-2004, 02:04 AM
  3. Parent record switches when entering in grandchild
    By Rick Hollowell in forum Alpha Five Version 4
    Replies: 11
    Last Post: 03-09-2001, 09:32 AM
  4. Parent record switches when entering in grandchild
    By Rick Hollowell in forum Announcements
    Replies: 2
    Last Post: 03-08-2001, 06:21 AM
  5. Filtering grandchild records problem
    By Anthony Cappelletti in forum Alpha Five Version 4
    Replies: 1
    Last Post: 09-29-2000, 09:09 AM

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
  •