Alpha Video Training
Results 1 to 8 of 8

Thread: copy

  1. #1
    Member
    Real Name
    BARRY MANN
    Join Date
    May 2005
    Posts
    48

    Default copy

    When editing a browse I am giving the user the opportunity to delete a record with a button (on event-delete). I need to copy the deleted record to another table called "deleted". (By the way...I only want to copy the record in focus at any time) I have tried the copy operation, but only get one record copied at a time and each copy erases the previous...Anyone have any input what I am doing wrong???

  2. #2
    Member Jenny Earnshaw's Avatar
    Real Name
    Jenny Earnshaw
    Join Date
    Feb 2001
    Location
    Hertfordshire, UK
    Posts
    77

    Default RE: copy

    This is how I did a similar thing:

    1. When the record to be deleted/copied was highlighted in the browese, the user clicked a button marked "Delete-Yes" which ran the following code to "mark" the record. Customer_List is the name of my browse.

    topparent:Customer_list.mark_record()

    2. After the records to be deleted/copied have been marked (could be only one record or as many as required) the user clicks another button called "Delete Marked" which did the following:

    a) Displayed a message box as follows:

    'Displays a message box (style:'OK, Cancel Buttons', image: 'Attention symbol', id: 'MSG_EXPCUST').
    DIM SHARED MSGEXPCUSTD_result as N
    DIM SHARED MSGEXPCUSTD_OK_Button as L
    DIM SHARED MSGEXPCUSTD_CANCEL_Button as L
    MSGEXPCUSTD_OK_Button = .F.
    MSGEXPCUSTD_CANCEL_Button = .F.

    title_var = "Deleted marked Customers"
    'Message is an expression. Need to evaluate the expression in the context of the current form.
    message_text_var = a5_eval_expression("=\"ALL Customers marked for deletion will be moved to the deleted customer's table.\"+chr(10)+chr(13)+\"Do you wish to continue?\"")
    MSGEXPCUSTD_result=ui_msg_box(title_var,message_text_var,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_ATTENTION_SYMBOL)
    'Test to see which button on the message box was pressed....
    SELECT
    CASE MSGEXPCUSTD_result = UI_OK_SELECTED
    MSGEXPCUSTD_OK_Button= .t.
    CASE MSGEXPCUSTD_result = UI_CANCEL_SELECTED
    MSGEXPCUSTD_CANCEL_Button= .t.
    END SELECT

    b) Cancel the proceedure if Cancel is selected.

    If MSGEXPCUSTD_CANCEL_button = .t.
    ui_Msg_Box("Delete Marked","Move operation cancelled!",16)
    stop
    end if

    c) If OK is selected:

    If MSGEXPCUSTD_OK_button = .t.

    query.filter = ""
    query.order = ""

    DIM operation_name as c
    operation_name = "Append_delete"
    If operation_name "" "" then
    append.run_silent(operation_name,query.filter)
    End if
    xbasic_wait_for_idle()

    query.filter = ""
    query.order = ""

    DIM operation_name as c
    operation_name = "Delete_Customers"
    If operation_name "" "" then
    mark.run_silent(operation_name,query.filter)
    End if
    end if

    The first operation: "Append Delete" appends all Customers who have been "marked" to a Deleted_Customers table.

    The second operation "Delete Customers" deletes all customers who are "marked" from the Customers table.

  3. #3
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: copy

    Barry,

    Check out "TBL".COPY_RECORD_TO(), it might be all you need.

    Scott

  4. #4
    Member
    Real Name
    BARRY MANN
    Join Date
    May 2005
    Posts
    48

    Default RE: copy

    don't think this will help in copying just the current record...

  5. #5
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: copy

    Barry,

    Are you deleting more then one record at a time?

    I would think that you are selecting the record in the browse, clicking the delete button.

    So your button script should first copy the current record in the browse to the new table "Deleted" and then delete the record from the browse table.

    Is this not what your trying to do?

    Scott

  6. #6
    Member
    Real Name
    BARRY MANN
    Join Date
    May 2005
    Posts
    48

    Default RE: copy

    One at a time and yes copy then delete in script action.

  7. #7
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default RE: copy

    OK, so assuming that your form is based on a set, and the set structure is:

    = Parent Table
    ==== Child table (the browse table)

    And your "Deleted" table has the same structure as the child table .... your code would be something like:

    DIM tbl as P
    tbl = table.current(2)
    'First copy the record to the "Deleted" table
    on error goto failed_to_copy
    result = tbl.copy_record_to("Deleted")
    on error goto 0
    if result then
    tbl.change_begin()
    tbl.delete()
    tbl.change_end(.t)
    end if
    end

    failed_to_copy:
    ui_msg_box("Record not copied.", error_text_get(error_code_get()))
    end


    Scott

  8. #8
    Member
    Real Name
    BARRY MANN
    Join Date
    May 2005
    Posts
    48

    Default RE: copy

    Scott: This works great...Thanks for the help !!

Similar Threads

  1. Copy to CD
    By Michael Humby in forum Alpha Five Version 4
    Replies: 8
    Last Post: 05-25-2005, 08:23 AM
  2. How do I copy only the db
    By David Gilbert in forum Alpha Four Version 6 and Prior
    Replies: 10
    Last Post: 02-26-2004, 04:38 PM
  3. Copy Appearance/Copy Format
    By dik_coleman in forum Alpha Five Version 5
    Replies: 6
    Last Post: 10-12-2003, 06:35 AM
  4. Copy will not run.....
    By Jeff Klages in forum Alpha Five Version 5
    Replies: 8
    Last Post: 11-02-2002, 02:57 AM
  5. Where is <tbl>.copy()?
    By Gary Kissinger in forum Alpha Five Version 4
    Replies: 4
    Last Post: 10-14-2001, 02:36 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
  •