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

SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

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

    SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

    I have a set. One parent, one child table no referential integrity. I need to run a query on the child table and remove any records from the child table that match the query. The child table is usually in change mode before I run this operation so, I check the mode of the child table and if it's CHANGE I do a tbl.change_end(.f.) then run the query. The problem I'm having is that when I put the child table into VIEW mode and run the query, it also appears to put the parent table into VIEW mode. Is there any way to prevent the parent table from going into VIEW mode when I do this?

    Here is the function I call to remove the records from the child table:

    Code:
    [COLOR=darkorange]FUNCTION RemoveRecordsPieceDesc AS N (tblnum as N, vFilter as C)[/COLOR]
     option strict
     
     DIM tbl as P
     DIM qry as P
     DIM numrecs as N
     DIM commit_flag as L
     DIM mode as N
     DIM name as C
     
      [COLOR="Red"]' get a pointer to the child table[/COLOR]
      tbl = table.current(tblnum)
     
      'name = tbl.name_get()[COLOR="red"] ' debug code[/COLOR]
     
      [COLOR="red"]' get the mode of the child table; usually CHANGE[/COLOR]
      mode = tbl.mode_get()
     
    [COLOR="red"] ' Put the child table into view mode[/COLOR]
      IF (mode == 1)
       tbl.change_end(.f.)
      ELSE IF (mode == 2)
       tbl.enter_end(.f.)
      END IF 
     
      [COLOR="red"]' If records in tablename match vFilter, delete them.[/COLOR]
      qry = tbl.Query_Create("",vFilter)
      numrecs = qry.records_get()
      WHILE (numrecs > 0) 
           commit_flag = .T.
           tbl.change_begin()
           ON ERROR GOTO error_handler
           tbl.delete()
           tbl.change_end(commit_flag)
     
           numrecs = numrecs - 1 
      END WHILE   
     
    [COLOR="red"]  ' Return the number of records that still match the query.
      ' 0 indicates success![/COLOR]
      RemoveRecordsPieceDesc = qry.records_get()  
     
      qry.drop()
     
      end
      '
     error_handler:
          commit_flag = .F.
       ui_msg_box("Error","Record number: "+ tbl.recno() + " was not deleted!")
     RESUME NEXT
    [COLOR=darkorange]END FUNCTION[/COLOR]
    Here's the script that calls the above function. It's attached to a dropdown box on my form:

    Code:
    [COLOR=red]' Get a pointer to the parent table[/COLOR]
     current_tbl = table.current()
     
    [COLOR=red]' Set vFilter = OConfirmID. (My linking field for the set)[/COLOR]
    [COLOR=red]' To be used with a5_get_records_in_query() and Record_Delete().[/COLOR]
     vFilter = "OConfirmID = "+ S_QUOTE(current_tbl.ordernumb)
     
     
    [COLOR=red]' IF there are any records in the child table "piecedesc" that [/COLOR]
    [COLOR=red]' belong to the current parent table's record, prompt the user.[/COLOR]
     IF (dbcount("piecedesc","Oconfirmid",Oconfirm->ordernumb) > 0)
         response = ui_msg_box("Warning!","The piece descriptions for this   
         order will be lost!  Are you sure you want to change this field?", 
         UI_QUESTION_SYMBOL+UI_YES_NO)
     
     [COLOR=red]' IF user clicks NO abort script.[/COLOR] 
     IF (response = UI_NO_SELECTED)
         cancel()
         end 
     ELSE [COLOR=red]' ELSE clear the value of the following dropdown boxes.[/COLOR]
         OConfirm_Form:combobox_piecedesc_stock.value = ""
         OConfirm_Form:combobox_piecedesc_size.value = ""
         OConfirm_Form:combobox_piecedesc_stockcolor.value = ""
         
         [COLOR=red]' CALL the function described in the first code snippet[/COLOR]
         result = [COLOR=darkorange]RemoveRecordsPieceDesc([COLOR="Black"]2, vFilter[/COLOR])[/COLOR]
      END IF 
    END IF    
     
    *******************************************************
    ************** [COLOR=red]HERE'S WHERE MY CODE FA[/COLOR][COLOR=red]ILS [/COLOR]*****************
    *******************************************************
    * The[COLOR=black][U][B]FIRST[/B][/U][/COLOR] time I try to set the .value of any of the fields on my form (which are bound to the parent table) [COLOR=blue](see the lines of code that fail are marked in [COLOR=red]red[/COLOR] below)[/COLOR] I get an error saying, "An Error Occured: Change must begin first" If I skip that line in the debug and continue executing the script, it's as if the table magically goes into CHANGE mode. The rest of the lines that set the .value property of the other fields on the form work fine. ??? Does anyone know why this is?
    *******************************************************
    [COLOR=red]' Usually shows the parent table is in VIEW mode.[/COLOR]
    mode = current_tbl.mode_get()
     
    [COLOR=red]' IF the parent table is in VIEW mode put it into CHANGE mode.[/COLOR]
    IF (current_tbl.mode_get() == 0)
     current_tbl.change_begin()
     
    ' The line in red is the line that fails... if I comment it out the next line that sets the .value property will fail. (Highlighted in blue)
     
     [COLOR=red]OConfirm_Form:COMBOBOX_OConfirm_Form_Maildrop.value = ""[/COLOR]
     OConfirm_Form:LBL_OConfirm_Form_Maildrop.hide()
     [COLOR=blue]OConfirm_Form:tif_piecedesc_envelope.value = ""[/COLOR]
     OConfirm_Form:lbl_piecedesc_envelope.hide()
    Last edited by Jeff@Listbrokers; 01-10-2007, 04:08 PM.

    #2
    Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

    I think you'll have to open a second instance of the child table

    tbl = table.open("tablename")

    This pointer should be independent of the set and should not cause the parent to change modes.
    There can be only one.

    Comment


      #3
      Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

      Thanks Stan, I'll try that real quick and let you know.

      Comment


        #4
        Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

        Ok... I used the
        Code:
         
        tbl = table.open(tblname)
        And my program seemed to hang (became unresponsive) when trying to remove the last record from the child table...??? COULD THIS BE BECAUSE THE SET HAS THAT RECORD LOCKED???

        Comment


          #5
          Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

          After some testing the record is indeed locked....

          1. why is the record locked?
          2. If a record is locked what are the ways I can unlock that record?

          a. commit the parent table?
          b. ???

          Comment


            #6
            Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

            Here's a copy of my app. If someone could help I would really appreciate it. I've been stumped on this one for a couple of days. The problem is in the OnChange Event of the top left dropdown box under the "Description" tab on the OConfirm_Form. Ha... if that's not convoluted I don't know what is. :)

            Steps:

            1. Open the form named OConfirm_Form and navigate to the Description tab
            2. you will see a dropdown box on the left. If you select "Mailer" from that dropdown another box will popup below that.
            3. Select "Letter", and another dd box will appear below it.
            4. Select any of the choices in this 3rd dd box. Another box will pop-up below that.
            5. In this box select two or three inserts. (any of the choices will work)
            6. Navigate to the third tab labeled "Piece Breakdown".
            7. Click the add button. If you selected two inserts click it twice, three inserts, three times... etc.
            8. Navigate back to the "Description" tab.
            9. Change the top left dd box (the one you selected "Mailer" from) to anything other than "Mailer". This will launch the script that I'm having trouble with.

            After you have entered records into the embedded browse under the "Piece Breakdown" tab, when you change the dd boxes on the "Description" tab the program should dump all of the child records stored in the table used by the embedded browse.

            Comment


              #7
              Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

              Jeff,
              Your instructions are no quite complete, but I got to the place about the inserts list... just enough to engage whatever it is that totally screws up my system. See attached image where the A5-.dll is locked as I migrate to the IE to look at your directions.

              I don't know what your sequence is doing, but it seems it isn't Kosher.
              Mike W
              __________________________
              "I rebel in at least small things to express to the world that I have not completely surrendered"

              Comment


                #8
                Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

                Originally posted by Mike Wilson View Post
                Jeff,
                Your instructions are no quite complete, but I got to the place about the inserts list... just enough to engage whatever it is that totally screws up my system. See attached image where the A5-.dll is locked as I migrate to the IE to look at your directions.

                I don't know what your sequence is doing, but it seems it isn't Kosher.
                Mike,

                Thanks again for looking at this problem for me.
                I'm sorry about that!!! I hope I didn't cause any damage to your OS. Did the program crash your system or was it just the hung .dll? Alpha seems to have that problem with dropdown boxes quite often. I've had that problem even on simple forms that didn't have any real scipt attached to the so to speak. I haven't been able to find what's cause that. If any of the Alpha guru's out there know what caused that I would really like to know why.

                Sorry about the poor instructions. Which part of the instuctions were unclear? After you select the number of inserts from the insert dropdown, goto the "Piece description" tab and click the "add" button a couple of times. A dialog box will pop up telling you that you have added the number of records to the child table (browse) that you told the program you wanted to enter in the "Inserts" dropdown. Once you have entered all the records, go back to the description tab and change the top left dropdown from "Mailer" to anyother value. This should launch the OnChange script that is causing the problem.

                Thank you again for taking the time look at this for me!

                Comment


                  #9
                  Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

                  Jeff,
                  The system hung on the .dll open. I had to get out of A5 to remove it. No problem. Except it kept on happening without fail! There is something in your operations that is not kosher.

                  The limit in your description of the sequence of events was that the inserts pop up did not happen in sequence but instead the sequence took me from the field '? letter size?' to the one next to it with "pick a color". No worries. I was able to get through to the next field. Except it had to do with matching-non-matching. What gives me difficulty, and possibly others, is that the sequence you took us on .... well... is, at least for me, somewhat convoluted and, for me, very hard to understand the process/endpoint, and I had a very hard time reproducing it, cleanly. I think I know what might be happening.

                  The direction you provided generates NOT a New Record event but a Record Change sequence. Foremost, the sequence you describe seemed to engage a record entry sequence ( maybe more than one, within a record change sequence within the record change sequence.

                  I think you are trying to have a DUMMY entry form with field events based upon the field entries in a form that is not cleared at the time of entry but is instaed in a change event with field values in place, and therefore engaging conditional rules, which is i turn making this whole sequence a mess.

                  Jeff, I'm sorry, but what you have going here is comprehensible only with heavy review and abundant conjecture. Again..

                  My guess, and only a guess... the issues are:
                  1. You are using a sequence based on a record change event with a record in place and not a record entry event. and therefore ...
                  2. You have in your script conditional actions based upon field values that become conflicted with a Record Change Sequence because they already have values???.

                  Big Guess but SORRY... I am lost in where you're trying to go, and the algorhythm you are trying to achieve.
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

                    Jeff,

                    I spent some time looking over this and I have to agree with Mike that what you are doing is very complex.
                    I did not however have any of the .dll problems. I am running this under V8 though.

                    I was able to get your script to do what I "think" you want it to do by two different changes both related to what I think is the problem.

                    In your script you set the values for the form objects related to the piecedesc table with a blank ("") value. You then call a function to delete all of the piecedesc records linked to the parent. Since you are deleting all of the children anyway why bother setting the form object values?

                    At this point you put the table into change mode but do not make any changes to the table, only to the form objects.
                    I removed the current_tbl.change_begin() part of your code here since I could not see what it was supposed to be there for.

                    Two different methods that I got to work are listed below. In both cases though I removed the current_tbl.change_begin() section.

                    One: Comment out all of the lines above this line that set the form object values to "".

                    Code:
                    result = RemoveRecordsPieceDesc(2, vFilter)
                    Two: Leave that section alone and add a parentform.commit() just after the above line.
                    Jim Coltz
                    Alpha Custom Database Solutions, LLC
                    A5CustomSolutions.com
                    [email protected]

                    Comment


                      #11
                      Re: SETS: Put the child table into VIEW mode without the parent going into VIEW mode?

                      Mike -- thanks again for taking the time out to look at my problem. I forgot about the "color" dropdown box, that was kinda of added to the program as an after thought. :) You're right, my program does have tons of interaction between which makes it incomprehensible, even to me. :D Thank you again for your time!

                      Jim -- your suggestion did the trick! I am eternally grateful, I had been staring at this code for sooo long that I wasn't able to see the forest for the trees. The statements that set the fields to "" were there because I hadn't quite figured out why the last record in the child table was locked. So I thought that the fields on the form might somehow have been resetting the last record in the child table... I was getting desperate. :) It was kind of the same senario with the current_tbl.change_begin() code. After deleting the records from the child table my script was supposed to reset/hide/show some of the fields on the form attached to the parent table. I kept getting an error stating that I needed to put the parent table into change mode, so there again I was guessing.

                      I removed all the lines that set the form object values to "".
                      I added the parentform.commit() as you suggested, and finally,
                      I removed all the code block where I had the current_tbl.change_begin().

                      Works like a charm! THANK YOU!

                      Comment

                      Working...
                      X