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

Calculated Field Uniqueness Oh My!

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

    Calculated Field Uniqueness Oh My!

    Well day two searching through Calculated Fields and check for Uniqueness and have failed to find what I need or contact a few of the people in that thread.

    I have three fields "Code", "TS_Number" and "Job_number" that I combine into one field called "All3". In field rules under "Field Types" "All3" is setup to be a calculated field and I have an expression that combines the above three fields.

    Up to here everything works fine.

    What I want to do is test "All3" for Uniqueness. The Validation field rule does not work when the field type is a calculated field. In some of the previous threads people talked as if the Validation field rules still worked. Others talked about putting unique validations on the individual fields. Yet others talk about indexes and events.

    I think that the indexes and events thing might work, but have failed to get enough detail to reproduce what I need. I have the index built (Not sure if it is correct) and had a "exist(All3,"jobs_test","Dup_Number")"function in the events under the "OnSaveRecord" again not sure if I did it right as A6 gives me an error stating that "Variable "All3" not found".

    Attached is a very simple striped down version that I have been trying to get to work so I can add it to another database.

    #2
    Originally posted by Chris A
    What I want to do is test "All3" for Uniqueness. The Validation field rule does not work when the field type is a calculated field.
    - you don't need to test "All3" for uniqueness. You can use the

    "Value of expression must be unique" - Use this setting when you want to build an expression to determine if a value is unique. The field for which this rule is defined is usually included in the Unique expression. The value that results from this expression must be unique for each record in the table; if not, the record cannot be saved.
    using the same expression that calculates the contents of the "All3" field.

    I think. Will experiment with your sample.

    Later: My research with the "Value of expression..." seems to work only when the field being validated is not itself a lookup field. You may want to pursue other avenues.
    Last edited by Stan Mathews; 03-02-2006, 02:13 PM.
    There can be only one.

    Comment


      #3
      maybe you can calculate your combined field through form level. make your field user entered at fieldrules and and from there you can set your field rule for uniqueness test.

      i hope this might help you out...

      Francis

      Originally posted by Chris A
      Well day two searching through Calculated Fields and check for Uniqueness and have failed to find what I need or contact a few of the people in that thread.

      I have three fields "Code", "TS_Number" and "Job_number" that I combine into one field called "All3". In field rules under "Field Types" "All3" is setup to be a calculated field and I have an expression that combines the above three fields.

      Up to here everything works fine.

      What I want to do is test "All3" for Uniqueness. The Validation field rule does not work when the field type is a calculated field. In some of the previous threads people talked as if the Validation field rules still worked. Others talked about putting unique validations on the individual fields. Yet others talk about indexes and events.

      I think that the indexes and events thing might work, but have failed to get enough detail to reproduce what I need. I have the index built (Not sure if it is correct) and had a "exist(All3,"jobs_test","Dup_Number")"function in the events under the "OnSaveRecord" again not sure if I did it right as A6 gives me an error stating that "Variable "All3" not found".

      Attached is a very simple striped down version that I have been trying to get to work so I can add it to another database.
      Francis

      Comment


        #4
        Chris,

        Here's one approach.

        1) change your index tag definition for the All3 field to include ALL records

        2) delete your OnSaveRecord field rule event script

        3) use this script in the CanSaveRecord field rule event:
        Code:
        tbl = table.current()
        if key_exist("dup_number",tbl.all3) then
           cancel()
           ui_msg_box("Oops","Duplicate key")
        end if
        -- tom

        Comment


          #5
          Tom could you explain a little more on your #1? I am not sure if I know how to include ALL records.

          I understand 2 and 3 they are straight forward.

          Comment


            #6
            Chris,

            "All3" is an index tag you have defined for the table. If you inspect your definition (in the index builder) you will see that you told Alpha Five to include only unique keys in this index list. I'm recommending you change this definition to include all keys in the index list. Change the definition and the rebuild the index.

            -- tom

            Comment


              #7
              How simple, I should have seen that myself. Thank You very much!
              This application works just the way I hoped and wanted.

              Comment


                #8
                New Curve ball. I have created a po_header and po_item linked together by a po_set. With this I have also created a job_set linking the po_item to job_test. Po_item also has "all3" in it. Now the event that checks for duplicates is picking up the "all3" in the po_item and not allowing changes. Is there a way to not check for duplicates in the po_item but only the job_test tables? Can the following be modified?

                tbl = table.current()
                if key_exist("dup_number",tbl.all3) then
                cancel()
                ui_msg_box("Oops","Duplicate key")
                end if
                Last edited by Chris A; 03-09-2006, 01:11 PM. Reason: Attaching revised Database

                Comment


                  #9
                  Tom could you take one more look at this. All the items that you gave me work fine. Now I have added another table with the same information and it thinks there is a duplicate when there really isn't. Thanks

                  Comment


                    #10
                    Re: Calculated Field Uniqueness Oh My!

                    Chris

                    How did you ever make out with your unique calculated field? I found this thread while trying to do the same thing. I want to provide a unique calculated field which is a combination of vendor_id and PN. I set up a calculated field in the "parts" table called "part_id" defined as alltrim(str(vendor_id))+alltrim(pn) and updated the table. Now, I need to catch any entries into the parts table that are duplicates of part_id.

                    do I put code on the CanSaveEvent as follows?

                    tbl = table.current()
                    if key_exist("dup_number",tbl.part_id) then
                    cancel()
                    ui_msg_box("Oops","Duplicate part")
                    end if
                    Jim Belanger

                    Comment


                      #11
                      Re: Calculated Field Uniqueness Oh My!

                      Answered my own question. I tried the code and got an error because I had not defined an index for part_id. When I did, it seems to work fine. Thanks Chris and Tom too.

                      OOPS: I spoke too soon. The CanSave script works well in identifying that I have a duplicate but it leaves the form in the ENTER mode instead of cancelling entries and bringing me back to the original VIEW mode. If I try to go to another record or do anything, it keeps telling me I have a duplicate. I have to press the Escape key and answer the question "Do you want to lose your changes" in order to get out. When I click OK on the ui_msg can I automatically cancel changes and get out of the ENTER mode?
                      Last edited by Beltronics; 07-13-2008, 09:45 AM.
                      Jim Belanger

                      Comment


                        #12
                        Re: Calculated Field Uniqueness Oh My!

                        This isn't working. Now, I can't edit a record. It says I already have this unique field. Duh, of course I have it but I want to edit it.
                        Jim Belanger

                        Comment

                        Working...
                        X