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

Set-Link by Expression

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

    Set-Link by Expression

    I have never used link by expression for a set before and was wondering in the following situation if it can be done, should be done, and would it help my situation.

    I have a table that should have both an arrival record for an aircraft (designated with an "A" in a field called "type") and a departure record (designated with an "D" in a field called "type"). I say should because sometimes when the parent reservation record is created only the arrival may be known and thus there would only be one record of an "A" type and no "D" record created yet.

    I have a need to compare many items between the arrival to the departure, for example to see what the time difference is between the two, or if a service was done on the arrival. I have been using filtered indexes and calculated fields such as:

    'Checks the existence of the departure if the record I am on is an arrival
    existd = if(type="A",exist(ALLTRIM(STR(RESNUM)+"D"),"res_detail","dupentryd"),.f.)
    'looks up the reservation date (rdate) for that departure
    existd1 = if(calc->existd=.t.,dtoc(lookupd("F",ALLTRIM(STR(RESNUM)+"D"),"rdate","res_detail","dupentryd"),"1-"),"")

    to get the data that I need. As there is quite a lot of this going on, the form is painfully slow. I would like to access the record directly and I was wondering if I could do this with a filtered set somehow.

    This means making the parent and child with the same table.

    I was thinking this would greatly speed things up. It is the same table which I thought would create issues, but I tried linking it on a one field parameter and it was allowed, and it worked. It did not work as intented, of course, but it did show me two records from the same table on one form.

    I did try a simple IF statement in the set linking and it did not work, but I wanted to ask about this practice, OR IS THERE A BETTER WAY. If so, how should the set link expression be constructed. I have never used this before and I was hoping for some sage advice.
    Last edited by johngtatp; 04-24-2013, 07:09 PM.

    #2
    Re: Set-Link by Expression

    well, My first thought is to take the work out of the index and place it in a funtion or a script. Function is usually better depending on what is done. It would only be activated when the departure of "D" was entered in a form.

    answer a question, I have a set where a table is included in a set 2 times(the second instance is an alias), but neither is the master in the set. It has performing excellent for years.

    I have a db right now that I am repairing and redoing. The previous programmer placed hard functions in the field rules and nearly stopped the app. there are(won't be later) many filtered indexes, very long table names and index names, haphazard sets, oversized memo files. Lots of work for me. No security on a very delicate app for information. Looks like it was slapped together in a week of part time work, many shortcuts in the work.

    I have another one coming up that is worse, if I get the job. Used 5 tables where 1 would be more efficient and memo files are almost 2 gig.
    Dave Mason
    [email protected]
    Skype is dave.mason46

    Comment


      #3
      Re: Set-Link by Expression

      Have you got another table that you could use as the header? Because this sounds like a general ledger scenario where you might want to link the same child table twice to show debits from the first and credits from the second. The 2nd instance of the child would then use the alias as Dave suggested. I don't think making the same table also a child of itself would work as you would like.

      Then you could do something for a set like - using each child with a different filter:

      PLANES
      ==>ARRIVALS ' TYPE = "A"
      ==>DEPARTURES 'TYPE = "D"
      Last edited by MoGrace; 04-24-2013, 10:07 PM.
      Robin

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

      Comment


        #4
        Re: Set-Link by Expression

        Dave,

        Having used alpha, very part time, for years, I have always struggled and learned through each project. Speed and design were never an issue because all of my projects have been small single user types. Being what I would call, a hack at this, makes me dangerous, but I do continually try to learn and do this better through the board. This current project was a huge undertaking, over my head mostly, that was written part time over the course of a year. I can think of many different ways to redo what I have done, but I am at a point where I am trying to make it work.

        Robin,

        Perhaps I can do this. This form shows all of the records for a given date. I might try this. Your analogy to a ledger is very close so perhaps this is an idea.

        LATER:

        I tried to set up the set with a parent and have one be the child and the same file to be the child of itself and that does not work. It says the file is in use. I tried in the linking field:
        if(Type="A",str(resnum)+"D",if(Type="D",str(resnum)+"A",str(resnum)+type))

        The common field is a reservation number, they each have the type field which is different. I need to display as a schedule, so I querry by a variable date to show a schedule for that day, but I need to reference the previous arrival or the future departure as for calculations and color fields. I was trying a "dummy" as the parent. I could not have each of them as a child as i need to have a one to one for the record and that is why I was trying to have it be a child of itself. I am not sure where to go with this.
        Last edited by johngtatp; 04-24-2013, 10:56 PM.

        Comment


          #5
          Re: Set-Link by Expression

          John,
          I have an old copy of your project from 2011 - I am sure you have progressed from the origninal design since that time - but it was interesting even then.

          I also have an old project of mine for a trucking/ warehouse company where a default 'master' list of charges is in one table and then for each customer, charges are selected from that list and assigned on a per customer basis. These were the normal fees to be charged each month while their goods were in house. Thus the charges eventually became the line items for the invoices and could be 'batch' selected for monthly billing while still allowing for 'extras'.

          It almost sounds like you are doing something similar whereby each 'tailnum' has a specific combination of services only they might utilize.
          Last edited by MoGrace; 04-24-2013, 11:08 PM.
          Robin

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

          Comment


            #6
            Re: Set-Link by Expression

            Yes, similar indeed. The main point to all of this was the status board, where each service has an associated color that is on multiple displays throught the facility. I originally wanted to do each service as a one to many to the aircraft reservation. I could not easily figure out an efficient and quick way to look through all the children for the 12 different services and look at the status for each (up to 4 possibilities eah), then color code a cell in an embedded browse, so I have one record for the arrival and one for the departure, and that record has all of the services within it. I can easily pull up a daily schedule and have all of the services easily color coded in a browse.

            Comment


              #7
              Re: Set-Link by Expression

              If my understanding is correct you have a master table of planes (flight numbers) and a detail table of plane activities - I assume that there is a unique identifier for a plane/flight and on the detail records a related date for a specific group of activities ( a flight) for that master UID, so on the detail table the overall master to detail identifier is plane(flight id) and date. If that is the case then the details should be structured as plane/flight id plus date plus sequence number say 0 for type "D" and 999 for type "A" (both created at the same time) followed by detail record time stamp - then every detail record sequence number created in between would be incremented as last sequence plus 1. It would not matter if the time of arrival was unknown in this scenario as it could be updated when known.

              Set would be :

              Master (plane/flight id)
              contents: plane/flight id
              PLUS whatever else

              One to many LINK to detail would be: plane/flight id = plane/flight id
              providing groups by: date + sequence no. + Type


              Detail (plane/flight id activities)
              contents: plane/flight id
              date
              sequence no.
              type
              PLUS whatever else

              For example:

              Plane\Flight Number: "BA1234"
              Description: "Boeing 747 Reg1234"

              Plane\Flight Number: "BA1234"
              Date: 12/12/2012
              Sequence: 0
              Type: "D"
              Time: "1220"
              Departure Time: "14:30"
              Arrival Time:
              Other Detail: ????


              Plane\Flight Number: "BA1234"
              Date: 12/12/2012
              Sequence:1
              Type: "R" (Refuel)
              Time: "1235"
              Departure Time:
              Arrival Time:
              Other Detail: ???

              Plane\Flight Number: "BA1234"
              Date: 12/12/2012
              Sequence:999
              Type: "A" (Arrival)
              Time: "1535"
              Departure Time:
              Arrival Time: 1800
              Other Detail: ???

              etc.
              Last edited by spudmurphy; 04-25-2013, 12:49 PM.

              Comment


                #8
                Re: Set-Link by Expression

                Before we all get confused(me mostly)
                what Robin meant and I eluded to is a header table. It is a table to connect the others to. It does not even have to have records in it, just the fields used for connection.

                as:

                myheader.dbf
                id1 connects table a
                id2 connects table b
                id3 connects table c

                my header.dbf is what you would build the set on.
                Dave Mason
                [email protected]
                Skype is dave.mason46

                Comment


                  #9
                  Re: Set-Link by Expression

                  Dave,

                  I tried this finally and have a header table (reservation) which has the Reservation Number (resnum) in it. I set this as the master table of the set and tried to link in a one to many link the reservation details (resdetails) twice; it is linked by the common resnum. I put a filter on each child tables, Type = "A" and Type ="B" for the other. When I try to open the default form or use the set in any way I get:

                  Error loading: Error adding relation child: The process cannot access the file because it is being used by another process.

                  Any thoughts?

                  Comment


                    #10
                    Re: Set-Link by Expression

                    John
                    Dave's suggested method is solid and efficient. Works every time.
                    Problem here being to picture what you expect this to look like.
                    There, for you to get the principle and make a working design.
                    Here's a working example. The only form - Flightform
                    Attached Files
                    Last edited by Ray in Capetown; 05-31-2013, 07:16 PM.

                    Comment


                      #11
                      Re: Set-Link by Expression

                      Ray,

                      Good morning I will look at this, thanks. This is what I was asking to do, but mine will not do that, I have to play with this some.

                      Comment


                        #12
                        Re: Set-Link by Expression

                        That single record single field table is all you need.
                        Then add you flight table twice, linked as the example.
                        If struggling then send me your chopped down flight table or set (zipped using the right click, zip - and the form will be included)

                        Comment


                          #13
                          Re: Set-Link by Expression

                          Thanks Ray.

                          I am working on this. I was trying to link it with just the resnum, then using a filter to restrict it and that is what is throwing the error. So perhaps this will do it. Thanks so much.

                          Comment


                            #14
                            Re: Set-Link by Expression

                            I never try filtering child tables - too much headache - this just uses fetch_first() when the link field changes

                            Comment


                              #15
                              Re: Set-Link by Expression

                              I tried setting it up. I got the error. I then set it up using a local copy with no one else on the network and it works. I then took the set definition and returned to the network enviornment and tried to open the default form and got the attached error: warning.jpg

                              I should be able to open a default form no matter if there are many users, right?

                              Comment

                              Working...
                              X