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

Autoincrement - idnumbers ....

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

    Autoincrement - idnumbers ....

    What would be the best way to automatically generate idnumbers that are based on the first 6 letters of the last name, plus a sequential number like 0000 - if there is already an idnumber based on this last name, then the suffix would be 0001.

    So, for example, if John Smith is entered, then his ID is SMITH0000. Then, if another John Smith is entered or even a Jane Smith, then their ID would be SMITH0001.

    Any help would be appreciated.

    Gary Traub
    Gary S. Traub, Ph.D.


    #2
    RE: Autoincrement - idnumbers ....

    Not sure how you would be able to keep count of the specific surname frequency, but if you are able to use a unique sequential number instead then you could do it by creating two fields.
    1.ID_Number, Character, Length 4 (or larger)
    Set the field rule to autoincrement.

    2.ID, Character Length 30 (or larger)
    Set the field rule to calculated and make the expresion something like this
    trim(surname)+trim(id_number)

    If you realy require the number to be based on the number of surname occurances, then maybe the count function could do it, but it may be tricky getting it to work quickly, and would probably work best in a default expresion as apposed to a calc.

    Note sure if that helped!
    Chris Tanti
    Technical Support

    Nuance & Fathom Ltd - The data-driven marketing agency

    Comment


      #3
      RE: Autoincrement - idnumbers ....

      Hi Chris,

      Thanks for your input. Actually, I had created a script that does the job and works quickly. I was just thinking that there might be a simpler way via field rules, but maybe not. Anyway, for anyone who is interested, here is the script that I use:

      newid.value=upper(alltrim(left(lastname.value,6)))
      newid.value=newid.value+"0000"

      dim tstr as c
      dim tstrnum as n
      tstr="0000"
      dim tid as c
      tid=newid.value

      dim tbl as p
      tbl=table.open("patients")
      query.filter="left(idnumber,6)=left(tid,6)"
      query.order="idnumber"
      query.options=""
      tbl.query_create()
      dim tn as n
      tn=0
      while .not. tbl.fetch_eof()
      tn=tn+1
      tbl.fetch_next()
      end while
      tbl.close()
      tstrnum=val(tstr)+1
      tstr=padl(alltrim(str(tn)),4,"0")
      newid.value=upper(alltrim(left(lastname.value,6)))+tstr

      idnumber.value=newid.value

      If anyone has a better way, please let me know. Thanks.

      Gary Traub
      Gary S. Traub, Ph.D.

      Comment


        #4
        RE: Autoincrement - idnumbers ....

        Will this be in a multi user environment?

        Have you tested it to be sure that it won't duplicate numbers if two users overlap work on the same client?
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          RE: Autoincrement - idnumbers ....

          Not really much better but you could do this right after the query_create():

          tbl.fetch_last()
          tstrnum = val(right( idnumber, 4 )) + 1

          The tbl.fetch_last() will only fetch to the last record in the query and, since it's sorted by ID number, the last one should have the highest value.

          Comment


            #6
            RE: Autoincrement - idnumbers ....

            If you had an index for just the last name and a field called sequence number, this would generate the sequence number and could be used as a default value, saved at end of data entry with a skip: Your id number could be a calc field based on last name and sequence. You have to be careful to consider multi-user possibilities. What if two people are entering a "smith" at the same time.

            RIGHT("0000" + LTRIM(STR(VAL(LOOKUPC("L",Last_name, "Sequence", "Customers", "Tag_lastname"))+1)),4)

            Comment


              #7
              RE: Autoincrement - idnumbers ....

              Regarding the possibility of foul-ups in a multi-user environment, what is the best way to avoid problems?Currently, what I do is to create the idnumber when the record is saved, thinking that it would be unlikely for two users to be saving a new record with the same name at exactly the same time. Is this the way to go?

              Gary
              Gary S. Traub, Ph.D.

              Comment


                #8
                RE: Autoincrement - idnumbers ....

                gary,
                i think your method will fail for persons with last names shorter than 6 characters.
                e.g.
                "Ng,Tran"
                you check for 6 identical characters in the last_name + number field, so
                NG0001
                will show up as a different last name than
                NG0002
                when you add the 2nd person with the last name of "Ng".

                Comment


                  #9
                  RE: Autoincrement - idnumbers ....

                  Hi Peter,

                  I just tested it and it does seem to work, at least on one machine. Here is what I did to test it out. I put in a person with first and last names of Aa i.e., the name I entered was "Aa, Aa". The script generated an idnumber of AA0000. I then entered another person with exactly the same name. The script generated an idnumber of AA0001. Am I missing the point?

                  Thaks for your help.

                  Gary
                  Gary S. Traub, Ph.D.

                  Comment


                    #10
                    RE: Autoincrement - idnumbers ....

                    Is this an id to link to child records?

                    What do you do when a person changes names? Married, divorced, etc.

                    What advantage is there in having the id field that includes part of the name?

                    When some significance is put into an id field, it usually causes trouble.
                    Al Buchholz
                    Bookwood Systems, LTD
                    Weekly QReportBuilder Webinars Thursday 1 pm CST

                    Occam's Razor - KISS
                    Normalize till it hurts - De-normalize till it works.
                    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                    When we triage a problem it is much easier to read sample systems than to read a mind.
                    "Make it as simple as possible, but not simpler."
                    Albert Einstein

                    http://www.iadn.com/images/media/iadn_member.png

                    Comment


                      #11
                      RE: Autoincrement - idnumbers ....

                      gary,
                      i think (at least from looking at your script) that the next time you enter some AA,AA, you will get another AA0001. i don't think you'll ever get to AA0002. i could be misunderstanding your code.
                      - peter

                      Comment


                        #12
                        RE: Autoincrement - idnumbers ....

                        Al:

                        points are well taken, but is there a better way?

                        Gary
                        Gary S. Traub, Ph.D.

                        Comment


                          #13
                          RE: Autoincrement - idnumbers ....

                          Peter:

                          You are 100% correct. I cannot see the error in the script though. Any suggestions? Thanks

                          Gary
                          Gary S. Traub, Ph.D.

                          Comment


                            #14
                            RE: Autoincrement - idnumbers ....

                            An help on this would be GREATLY appreciated. I am stumped.

                            Gary Traub
                            Gary S. Traub, Ph.D.

                            Comment


                              #15
                              RE: Autoincrement - idnumbers ....

                              KISS - Keep It Simple Stupid - It says that right on a sign in my office.

                              I refer back to that when I have trouble with things like this.

                              Why not have a simple unintelligent id field that serves as a linkage?

                              I still don't see the advantage that is gained by this numbering scheme that you are looking at. Enlighten us and we can help provide a solution.
                              Al Buchholz
                              Bookwood Systems, LTD
                              Weekly QReportBuilder Webinars Thursday 1 pm CST

                              Occam's Razor - KISS
                              Normalize till it hurts - De-normalize till it works.
                              Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                              When we triage a problem it is much easier to read sample systems than to read a mind.
                              "Make it as simple as possible, but not simpler."
                              Albert Einstein

                              http://www.iadn.com/images/media/iadn_member.png

                              Comment

                              Working...
                              X