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

Creating a Template to make a Table

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

    Creating a Template to make a Table

    In my online payroll program there is this feature I want to duplicate in my desktop app. Classification codes are set up for the Company by adding records in a table. These records then become fields in the Employee Classification table where checkboxes are used to select them for each employee. The Company classifications can then be selected as a master for filtering reports and record displays for Employees.

    In my payroll program the user can change, add or delete the Company codes and those changes will be reflected in the Employee table.

    The Company records look like this (I am assuming the IDCODE exists too):

    IDCODE CKBOX CLASS
    101 T/F Current PR
    102 T/F Salaried
    103 T/F Terminated

    There would have to be a limit to the number of records in the Company table like maybe 20 or 30 at most. In the Payroll progam the Company template shows all the fields as blank and any that are not filled in are not added to the Employee table.

    So I am guessing that the Employee Classification fields will look like this; plus adding a field to link to the Employee Data table:

    FILENO
    CKBOX101
    CLASS101
    CKBOX102
    CLASS102
    CKBOX103
    CLASS103

    That's about as far as I have gotten on how this would work. Any ideas?
    Last edited by MoGrace; 04-14-2007, 10:06 AM.
    Robin

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

    #2
    Re: Creating a Template to make a Table

    I'm not clear on what your question might be. There are methods like

    TABLE.ADD_FIELDS()
    TABLE_RESTRUCTURE()

    etc

    which will allow you to modify tables "on the fly".
    There can be only one.

    Comment


      #3
      Re: Creating a Template to make a Table

      Originally posted by Stan Mathews View Post
      I'm not clear on what your question might be. There are methods like

      TABLE.ADD_FIELDS()
      TABLE_RESTRUCTURE()

      etc

      which will allow you to modify tables "on the fly".
      Hi Stan,
      I am not real clear on what I am doing either :o

      I added 20 records to the Master and filled in 15, so five records have blank CLASS fields. In the form w/ embedded browse used to change these, all 20 records display and no more can be added.

      In the EE CLASS table, I used the fields like in my post above but without any CLASS### fields. On that form, I am using lookup calcs to get the Class names from the Master table so changes made there will show for each employee record. Also if any of the calcs are blank then no checkbox appears for selection.

      Now all I need to do is add a EE_CLASS record whenever I add a new employee. So far this is not too hard.

      What I want to do with this info is be able to create a query to filter the display of Employee records based on the selections in the Master table that match the EE_CLASS records.

      The set to display the form is structured like this:
      Employee
      ==>Co_Class (using a Link field of 'X')
      -->EE_Class (Link on FILENO)

      Since EE_Class is a child of Employee, I am not sure how to write the query for the browse that displays the Employee list. Also some filters would not work together - like Current PR and Terminated since that would show All records.

      Hopefully this makes more sense for what I am trying to do.
      Last edited by MoGrace; 04-16-2007, 02:34 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: Creating a Template to make a Table

        I changed the structure of the co_class table to match the structure of the ee_class table. The Set now looks like this:

        EMPLOYEE
        -->Mstclass
        -->EE_class (linked on FILENO)

        How do I write a query that would match all the ee_class records marked as .t. with the (one) mstclass record marked .t. and have it filter the Employee records? I did try the Query by Expression builder which lets me match the fields from both tables but it didn't give me any filtered results. I am definitely missing some concept here.

        If mstclass->chk04 = .t. then find where eeclass->chk04 = .t.
        Last edited by MoGrace; 04-19-2007, 11:00 PM.
        Robin

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

        Comment


          #5
          Re: Creating a Template to make a Table

          Robin, show us the current structure for the Mstclass and EE_class tables.

          For the Mstclass table explain what the fields mean if their names aren't self-evident.

          Are the links one to one or one to many (for Mstclass, and for EE_class)?

          It's sounding like you want to search horizontally within the fields of each record, instead of vertically through the records themselves. i.e. return those records where any of several fields contain a specific value. This kind of query is more difficult. Alpha Five is optimized to search vertically through the records... not horizontally through the fields, if you see what I mean. If I'm on the right track you should consider restructuring the Mstclass table so that instead of a series of fields for each possible classification (any one of which might be set TRUE), you have a single field, within which you store the classification field value itself. It's the field values that are important. Not the fieldnames. If you have a single field in some records it will be set to "Terminated" in others, "Salaried", in others "current PR", etc. Your search for "salaried" employees becomes easier to construct.
          Last edited by Tom Cone Jr; 04-20-2007, 05:44 AM.

          Comment


            #6
            Re: Creating a Template to make a Table

            Hi Tom,
            Well I have tried it both ways now and have not been able to get either way to work. But I think you are right and my first example makes more sense to me too. I think because I am trying to do the query on the primary through the child table linked to it one to one based on fields that match from another table I have overwhelmed myself here.

            If the EE_Class fields were contained in the Employee table, I know that would work, but I didn't want to add 40 more fields to that table.
            Robin

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

            Comment


              #7
              Tom - here's my query

              This actually works the first couple of times I push the button, but then I get an error. Is there a better way to write this query? I tried opening a 2nd instance of the table just to run the query but it didn't like that either.

              EDIT: Here is how I fixed it without a query:

              Code:
               
              dim ar[20] as p
              DIM recs as n = 0
              [COLOR="Navy"]'GET COUNT OF RECORDS MATCHING FILTER[/COLOR]
              [COLOR="Purple"]recs = tablecount("co_class","CHK=.T.")
              if recs = 0 then
                  ui_msg_box("No Class Selected","Please Select a Class to find",0)
                  end
              end if[/COLOR]
              [COLOR="navy"]'BUILD THE FILTER EXPRESSION FROM THE ARRAY[/COLOR]
              ar.initialize_from_table("co_class","CHK=.T.")
              DIM i as n
              DIM q_fltr as c
              i = 1
              FOR i = 1 to recs 
               if i = 1 then
              [COLOR="Navy"]'This creates the matching field name in 1:1 linked table[/COLOR]  
                q_fltr = "EE_CLASS->CHK"+ar[i].id+"=.t."
               else
                q_fltr = q_fltr+".and."+"EE_CLASS->CHK"+ar[i].id+"=.t."
               end if
              NEXT
              trace.WriteLn("Filter Exp: "+q_fltr)
              [COLOR="navy"]'RUN THE QUERY AND DISPLAY IN BROWSE[/COLOR]
              recs_found = topparent.queryrun(q_fltr,"","","No","<Cross Level>",.F.)
              if recs_found <=0 then
                  topparent.Show_all()
                  ui_msg_box("Query Results","No Records Found",0)
              end if
              browse1.fetch_first() [COLOR="navy"]'employee records - parent[/COLOR]
              browse2.fetch_first() [COLOR="navy"]'co_class records 1:N[/COLOR]
              Last edited by MoGrace; 04-20-2007, 03:18 PM.
              Robin

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

              Comment


                #8
                Re: Tom - here's my query

                Try changing INDX.drop() to

                parentform:tables:co_class.query_detach_all()
                There can be only one.

                Comment


                  #9
                  Re: Tom - here's my query

                  Thanks Stan I will try that!

                  Oops that generates an Error 1051. Where do you find these error codes explained?

                  Found it (I am getting better at searching in this forum!)

                  "Active relation uses that index"

                  My other error in the script above - 1003 is "No such field" and I have no idea why it tells me that.
                  Last edited by MoGrace; 04-20-2007, 02:37 PM.
                  Robin

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

                  Comment


                    #10
                    Re: Tom - here's my query

                    Originally posted by MoGrace View Post
                    Thanks Stan I will try that!

                    Oops that generates an Error 1051. Where do you find these error codes explained?

                    Found it (I am getting better at searching in this forum!)

                    "Active relation uses that index"

                    My other error in the script above - 1003 is "No such field" and I have no idea why it tells me that.
                    Different flavor of the same error. If the index/query is in use, you can't drop or detach it.
                    There can be only one.

                    Comment


                      #11
                      Re: Tom - here's my query

                      Stan,
                      I didn't need a query in the first place since TABLECOUNT() will get me the records in the filter without opening the table at all.

                      Sometimes there is just too much information to remember...

                      I edited the button script above and it works great. All I need is some user prompts for mix matched selections.
                      Robin

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

                      Comment

                      Working...
                      X