Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Delete Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Delete Error

    Hi All

    Trying to delete child records on a desktop form.

    The parent form, which is dimmed as frm_int, has 5 possible child tables that may contain records that need to be delete along with the parent.

    The below code will work correctly for the first child (Regadless of what table i use) and will delete the header, but will will not delete any of the other child records.

    Code:
    mode = parentform.mode_get()
    if mode = "ENTER" .or. mode = "CHANGE" then
     msgbox("Oops", "Must save or cancel pending edits first")
     end
    end if
    
    dim frm_int as P
    frm_int = table.open("table_interaction")
    
    dim frm_serv as P
    frm_serv = table.open("table_service_request")
    
    dim frm_serv_up as P
    frm_serv_up = table.open("table_service_request_followup")
    
    dim frm_img as P
    frm_img = table.open("table_image")
    
    dim hdr_ptr as P 
    hdr_ptr = table.open("table_shipping")
    
    dim parts_ptr as P
    parts_ptr = table.open("table_shipping_parts")
    
    
    vn_curr_ord = parentform:int_id.value  ' get the curr stock order
    'msgbox("int id", ltrim(str(vn_curr_ord)))
    
    parts_recs_count = a5_get_records_in_query("table_shipping_parts","int_id = " +vn_curr_ord)
    
    'msgbox("parts recs count",ltrim(str(parts_recs_count)))
    
    if parts_recs_count > 0 then
     ' parts are available to be del from this order
     query.filter = "int_id = vn_curr_ord"
     query.options = "T"
     idx = parts_ptr.query_create()
     
     'msgbox("part recs count", ltrim(str(idx.records_get)))
    else
     'no parts records to delete
     goto del_hdr 
     
    end if
    
    
    ' delete parts on this order
    parts_ptr.fetch_first()
    
    'debug(1)
    while .not. parts_ptr.fetch_eof()
     
     parts_ptr.change_begin()    'delete the current parts record
     parts_ptr.delete()
     parts_ptr.change_end(.t.) 'after the del A5 advances to next record automatically
    
     xbasic_wait_for_idle()  ' this line may possibly be deleted
     
    end while 
    
    parts_recs_count = a5_get_records_in_query("table_image","int_id = " +vn_curr_ord)
    
    'msgbox("parts recs count",ltrim(str(parts_recs_count)))
    
    if parts_recs_count > 0 then
     ' parts are available to be del from this order
     query.filter = "int_id = vn_curr_ord"
     query.options = "T"
     idx = frm_img.query_create()
     
     'msgbox("part recs count", ltrim(str(idx.records_get)))
    else
     'no parts records to delete
     goto del_hdr 
     
    end if
    
    
    ' delete parts on this order
    frm_img.fetch_first()
    
    'debug(1)
    while .not. frm_img.fetch_eof()
     
     frm_img.change_begin()    'delete the current parts record
     frm_img.delete()
     frm_img.change_end(.t.) 'after the del A5 advances to next record automatically
    
     xbasic_wait_for_idle()  ' this line may possibly be deleted
     
    end while 
    
    parts_recs_count = a5_get_records_in_query("table_shipping","int_id = " +vn_curr_ord)
    
    'msgbox("parts recs count",ltrim(str(parts_recs_count)))
    
    if parts_recs_count > 0 then
     ' parts are available to be del from this order
     query.filter = "int_id = vn_curr_ord"
     query.options = "T"
     idx = hdr_ptr.query_create()
     
     'msgbox("part recs count", ltrim(str(idx.records_get)))
    else
     'no parts records to delete
     goto del_hdr 
     
    end if
    
    ' delete parts on this order
    hdr_ptr.fetch_first()
    
    'debug(1)
    while .not. hdr_ptr.fetch_eof()
     
     hdr_ptr.change_begin()    'delete the current parts record
     hdr_ptr.delete()
     hdr_ptr.change_end(.t.) 'after the del A5 advances to next record automatically
    
     xbasic_wait_for_idle()  ' this line may possibly be deleted
     
    end while 
    
    parts_recs_count = a5_get_records_in_query("table_service_request","int_id = " +vn_curr_ord)
    
    'msgbox("parts recs count",ltrim(str(parts_recs_count)))
    
    if parts_recs_count > 0 then
     ' parts are available to be del from this order
     query.filter = "int_id = vn_curr_ord"
     query.options = "T"
     idx = frm_serv.query_create()
     
     'msgbox("part recs count", ltrim(str(idx.records_get)))
    else
     'no parts records to delete
     goto del_hdr 
     
    end if
    
    
    ' delete parts on this order
    frm_serv.fetch_first()
    
    'debug(1)
    while .not. frm_serv.fetch_eof()
     
     frm_serv.change_begin()    'delete the current parts record
     frm_serv.delete()
     frm_serv.change_end(.t.) 'after the del A5 advances to next record automatically
    
     xbasic_wait_for_idle()  ' this line may possibly be deleted
     
    end while 
    
    parts_recs_count = a5_get_records_in_query("table_service_request_followup","int_id = " +vn_curr_ord)
    
    'msgbox("parts recs count",ltrim(str(parts_recs_count)))
    
    if parts_recs_count > 0 then
     ' parts are available to be del from this order
     query.filter = "int_id = vn_curr_ord"
     query.options = "T"
     idx = frm_serv_up.query_create()
     
     'msgbox("part recs count", ltrim(str(idx.records_get)))
    else
     'no parts records to delete
     goto del_hdr 
     
    end if
    
    
    ' delete parts on this order
    frm_serv_up.fetch_first()
    
    'debug(1)
    while .not. frm_serv_up.fetch_eof()
     
     frm_serv_up.change_begin()    'delete the current parts record
     frm_serv_up.delete()
     frm_serv_up.change_end(.t.) 'after the del A5 advances to next record automatically
    
     xbasic_wait_for_idle()  ' this line may possibly be deleted
     
    end while 
    
    '
    del_hdr:
    ' now delete the frm for this order
    query.filter = "int_id = vn_curr_ord"
    query.options = "T"
    idx = frm_int.query_create()
    frm_int.change_begin()
    frm_int.delete()
    frm_int.change_end(.t.)
    
    
    ' now cleanup on the way out
    
    parts_ptr.close() 'close all the open tables
    hdr_ptr.close()
    frm_int.close()
    frm_serv.close()
    frm_serv_up.close()
    frm_img.close()
    
    
    'Close the current window.
    'check that you are in a window
    if is_object(topparent.this) then 
    	topparent.close(.f.)
    end if
    
    end
    Any ideas on what I am doing wrong?
    Last edited by ADCO Service; 04-10-2013, 07:39 PM.

    #2
    Re: Delete Error

    See this thread for some pointers.

    http://msgboard.alphasoftware.com/al...hlight=.delete


    When working on a form with a single parent visible (naturally) any code which processes child, grandchild, etc records using table current(#) affects only records related to the current parent.
    There can be only one.

    Comment


      #3
      Re: Delete Error

      Hi Stan,
      It looks like Melvin is wanting to delete records in tables not currently associated in a set based form, which is what the other thread is about. If that is not the case then why open all those other tables to do queries in order to find the records?
      Robin

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

      Comment


        #4
        Re: Delete Error

        Robin,

        You may be correct but the explanation of the intent at the start of the thread says otherwise (to me).
        There can be only one.

        Comment


          #5
          Re: Delete Error

          Stan,
          It did to me too until I looked at his script. I have tables for example that belong to a Customer but do not have keys to link them directly - like invoice items on an invoice that are linked to the Inv_no not the Cust_id. Which is only an example for illustration. But there might be a similar case for how to get rid of indirectly related records. We'll have to see I guess if that is his scenario or not.
          Robin

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

          Comment

          Working...
          X