Alpha Video Training
Results 1 to 7 of 7

Thread: what is correct syntax to allow update to my selected records?

  1. #1
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    732

    Default what is correct syntax to allow update to my selected records?

    Having got the fetching method to work, my next head scratcher is how to update the records. My failed attempts are highlighted in blue, the fields I want to update are in Red.
    the fetching on the child table works fine, just cannot find the correct syntax to be able to change each selected record. Any Suggestions please?

    Code:
    dim shared set_ptr as P
    dim shared parent_ptr as p
    dim shared child_ptr as p
    dim global vLocationOrder     as c
    dim global vLoggingWhen       as d
    dim global vLoggingWhere      as c
    set_ptr = set.open_session("enterreglogging.set")
    parent_ptr = set_ptr.enterreginput
    child_ptr  = set_ptr.logging
    filter = ".t."
    query.filter = "flattenquery("+filter+")"
    qry = parent_ptr.query_create()
    set_ptr.fetch_first()
    while .NOT. set_ptr.fetch_eof()
        if isblank("child_ptr.as") then
            ui_msg_box("",child_ptr.reg)
            
    '        child_ptr.allow_change(.t.)
    '        child_ptr.change_mode()
    
            child_ptr.when  = var->vLoggingWhen
            child_ptr.where = var->vLoggingWhere
            child_ptr.h     = var->vLocationOrder
            child_ptr.as    = child_ptr.reg
            
    '        :EnterRegLogging:Tables:logging.change_begin()
    '        :EnterRegLogging:Tables:logging.where = var->vLoggingWhere
    '        :EnterRegLogging:Tables:logging.when  = var->vLoggingWhen
    '        :EnterRegLogging:Tables:logging.h  = var->vLocationOrder
    '        :EnterRegLogging:Tables:logging.reg  = child_ptr.reg
    '        :EnterRegLogging:Tables:logging.change_end(.T.)
    '        topparent:Control_browse1.refresh_layout()
            trace.writeln(child_ptr.reg+" was logged","Logging")
        else
            trace.writeln(child_ptr.reg+" seen on "+child_ptr.when,"Logging")
        end if
        set_ptr.fetch_next()
    end while
    set_ptr.close()
    parentform.Resynch()
    I should add that the table is a saved table embedded in the parent form. This Code is on a button.
    I have OnDblClick event working fine for individual records, but want the facility to update all filtered records at times.
    Last edited by Graham Wickens; 02-27-2019 at 08:11 AM.
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  2. #2
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    732

    Default Re: what is correct syntax to allow update to my selected records?

    Quote Originally Posted by Graham Wickens View Post
    Having got the fetching method to work, my next head scratcher is how to update the records. My failed attempts are highlighted in blue, the fields I want to update are in Red.
    the fetching on the child table works fine, just cannot find the correct syntax to be able to change each selected record. Any Suggestions please?

    Code:
    dim shared set_ptr as P
    dim shared parent_ptr as p
    dim shared child_ptr as p
    dim global vLocationOrder     as c
    dim global vLoggingWhen       as d
    dim global vLoggingWhere      as c
    set_ptr = set.open_session("enterreglogging.set")
    parent_ptr = set_ptr.enterreginput
    child_ptr  = set_ptr.logging
    filter = ".t."
    query.filter = "flattenquery("+filter+")"
    qry = parent_ptr.query_create()
    set_ptr.fetch_first()
    while .NOT. set_ptr.fetch_eof()
        if isblank("child_ptr.as") then
            ui_msg_box("",child_ptr.reg)
            
    '        child_ptr.allow_change(.t.)
    '        child_ptr.change_mode()
    
            child_ptr.when  = var->vLoggingWhen
            child_ptr.where = var->vLoggingWhere
            child_ptr.h     = var->vLocationOrder
            child_ptr.as    = child_ptr.reg
            
    '        :EnterRegLogging:Tables:logging.change_begin()
    '        :EnterRegLogging:Tables:logging.where = var->vLoggingWhere
    '        :EnterRegLogging:Tables:logging.when  = var->vLoggingWhen
    '        :EnterRegLogging:Tables:logging.h  = var->vLocationOrder
    '        :EnterRegLogging:Tables:logging.reg  = child_ptr.reg
    '        :EnterRegLogging:Tables:logging.change_end(.T.)
    '        topparent:Control_browse1.refresh_layout()
            trace.writeln(child_ptr.reg+" was logged","Logging")
        else
            trace.writeln(child_ptr.reg+" seen on "+child_ptr.when,"Logging")
        end if
        set_ptr.fetch_next()
    end while
    set_ptr.close()
    parentform.Resynch()
    I should add that the table is a saved table embedded in the parent form. This Code is on a button.
    I have OnDblClick event working fine for individual records, but want the facility to update all filtered records at times.
    I can read, filter and display the records, surely there must be a way of updating the records, I just cant find it and Ive run out of things to try :((((((((((((
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  3. #3
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,557

    Default Re: what is correct syntax to allow update to my selected records?

    Look at change_begin() and change_end()
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  4. #4
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,062

    Default Re: what is correct syntax to allow update to my selected records?

    Graham

    What is
    ' :EnterRegLogging:Tables:logging
    ?

    Where is pointer(?) and came from?
    Last edited by johnkoh; 02-27-2019 at 09:07 PM.

  5. #5
    Member Graham Wickens's Avatar
    Real Name
    Graham Wickens
    Join Date
    Apr 2000
    Location
    Gloucestershire, UK
    Posts
    732

    Default Re: what is correct syntax to allow update to my selected records?

    Quote Originally Posted by johnkoh View Post
    Graham

    What is ?

    Where is pointer(?) came from?
    EnterRegInput is tablename
    --
    Support your local Search and Rescue Unit, Get Lost!

    www.westrowops.co.uk

  6. #6
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,062

    Default Re: what is correct syntax to allow update to my selected records?

    All I know....
    'dim shared child_ptr as p

    fetch Set_record

    fetch child record
    child_ptr.change_begin()
    ....
    child_ptr.change_end(.t.)
    I am not sure that you can use the Change or Enter table records when the set changed to "Flatten" mode.

    may be this, https://forum.alphasoftware.com/show...t.open_session

  7. #7
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,584

    Default Re: what is correct syntax to allow update to my selected records?

    I know the logic of fetching thru a set is probably sound but I would do it differently. I would open the parent table and then open the child table using a query that selects the matching parent link field. You can then fetch the parent, update the query filter for the child and fetch thru the child records making your changes and then fetch the next parent, etc.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. how to update multiple selected records?
    By fddizon in forum Alpha Five Version 10 - Desktop Applications
    Replies: 13
    Last Post: 11-13-2017, 09:15 PM
  2. How to Update Selected Records with SQL, using the checkbox select column?
    By cpgood in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 06-06-2016, 10:45 PM
  3. Correct Syntax help
    By doula in forum Application Server Version 10 - Web/Browser Applications
    Replies: 4
    Last Post: 10-01-2011, 04:39 AM
  4. Correct Filter Syntax
    By jwolfe11 in forum Alpha Five Version 8
    Replies: 1
    Last Post: 05-14-2007, 05:46 PM
  5. correct syntax for this query
    By crimmelcp in forum Alpha Five Version 5
    Replies: 1
    Last Post: 07-09-2004, 08:59 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
  •