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

Auto Increment Help...

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

    Auto Increment Help...

    Hello, I have several salesman that have a sales program that we created for their sales calls. Each salesman has a "unique" sales id that started with the first initial of there first, middle and last name plus 000101 (ie Steve Micheal Brown started out as SMB000101). Every week the sales staff emails there sales call table to myself at which time I append each table to my pc. One of the ways I'm able to append over 20k records from several different salesman with unique id's, is to set the "Extended field types" in the table's field rules to "User Entered" therefore keeping each sales call unique to each salesman and keeps the sales id matching what is on there computer, which allows data to be appended weekly.

    But by setting the field rules of the table on the sales id to "user entered" has one draw back, it doesn't allow me to enter my own sales calls on the same database. I would like the ability to enter new sales calls. Is there anyway that when I press a "New Sales Call" button in our sales program that it would allow me to create a new sales call starting with my unique ID (JBK000101) and auto increment each time I enter a "new" sales call.

    Again, I need to continue to have the ability of appending data from several salesmen with there own IDs and would like enter my own sales calls.

    Thank you in advance....

    #2
    Re: Auto Increment Help...

    Not with an autoincrement rule. You'll have to code the local button to find the maximum sales id in the jbk series, increment that, and use the new value as the new sales id.

    my_id = tablemax("sales_call_table_name","left(sales_id,3) = 'JBK'","sales_id")
    new_id = increment_value(my_id)
    There can be only one.

    Comment


      #3
      Re: Auto Increment Help...

      Stan, current maximum sales id for jbk series is "jbk002415". Do I need to put this max sales id for jbk in anywhere in you supplied code? If so where?

      Comment


        #4
        Re: Auto Increment Help...

        Using the attached database as an example, I have entered a few example sales records, with "unique sales id" for the salesman. What I would like to accomplish is by presses "new button" create a new record for salesman "jbk" which would be "jbk00105" and increment from this. As I indicated in my starting thread, I can't change the "sales call id" in the table's field rules to auto increment due to the fact of appending sale call data from other salesmen on a weekly bases. But I would like to enter sales calls with the same computer / database I append to. If someone could please show me using the attached database, it would be appreciated....

        PS: Stan thanks for the code in your previous code, I just can't seem to make it work, thus the example database.... JON
        Attached Files

        Comment


          #5
          Re: Auto Increment Help...

          Sample.Auto Increment.zip
          There can be only one.

          Comment


            #6
            Re: Auto Increment Help...

            Good Morning Stan, thank you for the code and zip file. I downloaded you example and tried it but it stills is not auto incrementing the JBK sales id. If you create a new sales record, it will start the next sales id as JBK00105 and thats exactly what I was looking for but if I save that sales record and start another, and its keeps the sales id at JBK00105 and it should be JBK00106 and the next one should be JBK00107 etc.... Thanks again.... JON

            Comment


              #7
              Re: Auto Increment Help...

              Change all your records to JBK instead of jbk and it will work.
              There can be only one.

              Comment


                #8
                Re: Auto Increment Help...

                Works great!!! Thanks Stan... JON

                Comment


                  #9
                  Re: Auto Increment Help...

                  The issue was that tablemax() was finding jbk0104 as the maximum each time and it was incremented to JBK0105. When all jbk records are changed to JBK then the tablemax() finds the right JBK record and the process works properly.
                  There can be only one.

                  Comment


                    #10
                    Re: Auto Increment Help...

                    Just to have it be shown, you can choose to change the field rules from one to another and back, so you could suspend the autoincrement, import, and then revert it back using the attached code. It is a dialog that the user selects tables and fields in the app to switch from one data entry type to another. (BTW, I'm pretty sure Stan helped me get this together a while back. Thanks Stan!)

                    Later:
                    You can't change the field rules for a table that a form is based upon so this would have to be called from else where like from a menu button. The code actually doesn't allow you to choose an open table. You can run it in IW and it works from there.
                    Attached Files
                    Last edited by Mike Wilson; 01-16-2012, 05:12 PM. Reason: Added point
                    Mike W
                    __________________________
                    "I rebel in at least small things to express to the world that I have not completely surrendered"

                    Comment


                      #11
                      Re: Auto Increment Help...

                      Thanks Mike... Stan's solution work for me but I'll give your code a test drive to see what it does differently....JON

                      Comment


                        #12
                        Re: Auto Increment Help...

                        A related question regarding the merits of different approaches to setting up unique fields:

                        Looking for a good argument as to why I shouldn't create a "user entered" character based calculated (unique) field with dbf's.....
                        (As opposed to a numerical or character+number [character based] auto-incrementing field.)

                        Due to "flexibility" considerations (update-ability and formatting/characters [3 vs. 00003] etc.): I would think it would be "generally preferable" to create a "user entered" aka: code generated unique field (character based with coding that guarantees uniqueness.) ~ Unless of course you're worried about records being deleted by accident or malicious intent.....

                        Notes:
                        This is for a top level table.
                        It will unlikely ever become a child/linked table. (Although that definitely is a consideration with regards to being able to change the value of the field at some point while linking etc.)
                        This field is also being assigned by a user behind a PC. (Another consideration relative to it being "user entered.")
                        It is possible that this table will at some point be ported to SQL.
                        (I suspect there are still issues/incompatibilities when using "non numeric compliant" fields with most back end databases if you're trying to achieve "auto-incrementing" via the database engine itself.)

                        First I was thinking about about TRX-000001 TRX-000002 TRX-000003 etc., as apposed to the numbers 1,2,3 etc. for the unique field.
                        Then began thinking about a schema like: vc_DateAndTimeStamp + chr(45) + vc_UserID for uniqueness in a hand coded "user entered" field.

                        I presume the only reason to go with a standard auto-increment numerical field (as opposed to an auto-increment field like TRX-00001) is related to theoretical limits on numbering schema?
                        (Setting TRX-01 as the default value would only allow 99 entries.)

                        And if you intend to link it as a child table using a an expression like left(ChildTable->UniqueID,3) then a character based auto-increment field would be preferable?
                        (Which in this case could effectively link all the TRX-????? child table records to one parent record entry of "TRX." ~ Very flexible!)

                        The thing is, creating a unique "user entered" field something like: vc_UniqueID = DateAndTimeStamp_fnc(now()) + chr(45) + vc_UserID provides the future opportunity to update that field at a later point in time. TONS OF FLEXIBILITY!?! (Only downside I see is if you decide to write code so that a computer begins adding records instead of a user. ~ Potential uniqueness issues.)

                        Maybe I've answered my own questions here.... I just wonder what I'm missing in terms of aspects I may not be thinking about. (efficiency etc.) ~Bizarre questions to ask, particularly when the "desktop part" of this application is close to being finished, and in a "version 2" state!


                        *
                        Last edited by SNusa; 01-29-2015, 05:55 PM.
                        Robert T. ~ "I enjoy manipulating data... just not my data."
                        It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                        RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                        Comment


                          #13
                          Re: Auto Increment Help...

                          Robert, I am working on an app right now where the ai fields were character. The first thing I did was to switch those to numeric. I do use them for things like table connectors and lookups behind the scenes. They are not viewable by the user. This app has several tables with over 300,000 records.
                          They have other fields that HAVE to be user enter in some way. Some are not editable once filled in.
                          The speed of the app has been increased a lot with simple index and ai record uses. Especially when it comes to queries and filters.
                          When you start adding fields together and adding date and time, how do you use that for table connections in a set? Just think about it.
                          Dave Mason
                          [email protected]
                          Skype is dave.mason46

                          Comment


                            #14
                            Re: Auto Increment Help...

                            Hi Dave!
                            So you're saying a simple auto-increment (numerical) field has proven itself significantly faster than alpha-numeric ai (and not auto-incremental) fields when you aren't thinking about adding in "trickery?" (trickery ie: linking fields based on an expression etc.)

                            You reply just reminded me of something else..... I thought there was a multi-user locking issue (Not only when concurrent users have to wait until initial save/topparent.commit()), but ALSO other possibilities for timing conflicts when 2 users try to start/save a new parent record simultaneously) with auto-incremental fields. (Regardless of whether they are simple numerical or alpha-numerical ai fields.)

                            So my followup question is: If this is the case.... Wouldn't a unique primary field assignment like like the following (user generated type) make more sense? (and possibly even speed things up in multi-user scenario's)

                            TIME("yyyy-MM.dd:0h0m.s3") + chr(45) + Var->vc_UserID
                            (where vc_UserID is a global variable assigned at login)

                            This is what you get with that expression: 20150129:173304.473-RWT (Where the RWT represents the appended initials of the user logging in as pulled from a user account table.)
                            This guarantees uniqueness in a multi user scenario.

                            The added benefits (beside the field lengths) is you get so much extra visually recognizable data, right down to the user who was logged in.
                            I know it's a big field in terms of character length, but it sure has some appeal IMO.

                            I just remember years back so much had been said about the dangers of using auto-incrementing fields. Just thinking out loud here.
                            Last edited by SNusa; 01-30-2015, 02:44 AM.
                            Robert T. ~ "I enjoy manipulating data... just not my data."
                            It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                            RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                            Comment


                              #15
                              Re: Auto Increment Help...

                              The rule of thumbs as has been shared with me by mature, seasoned database developers is that the field that you use for establishing uniqueness is the field you use for uniqueness and linking child records, and that's it. If you want some type of identification for who generated the record, when and where, then make a field for that, but don't combine a field for record uniqueness and a field for something else together.

                              I personally use a table (I name it QID for uniQue ID) that has one record for each table in the database with the record holding the next unique number for the next records in that table. Then I have qid_get(tablename as C), a UDF that acquires the next record ID from the QID table (RW_exclusive), increments it, replaces the acquired QID with the increment, and delivers the acquired QID to the script that called qid_get() which is making the new record. I use exclusively character fields for my ID because I prefix the ID with three letters of the table name for a second layer of uniqueness ( QID for the Projects table is PRJ.0000001, Customer table is CUS.0000001 ). It works very well!
                              Mike W
                              __________________________
                              "I rebel in at least small things to express to the world that I have not completely surrendered"

                              Comment

                              Working...
                              X