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

sequential numbering - should I start in Access backend or A5

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

    sequential numbering - should I start in Access backend or A5

    I've read a large number of posts on the topic of sequential numbering, but they all start a bit ahead of where I am. Could someone get me started please?

    My database helps company 'branches' keep track of their 'projects.' Each branch wants to identify their project by a 'number' once the project is 'approved.' The 'string/number' is to take the form 'number / year,' as below. Projects are assigned numbers only once they have an ApprovedDate. The table should look something like this (if it prints OK):


    ProjectID BranchID ApprovedDate 'Number'
    1 12 1/2/2013 1/13
    2 12 1/4/2013 2/13
    3 12
    4 14 3/4/2013 1/13
    5 14 3/5/2013 2/13
    6 12
    7 12 6/7/2013 3/13

    I use Access as a backend. Access solutions tend to work through the 'form,' which doesn't apply in this situation. Should I plan to get Access to generate the 'number' in the projects table once the ApprovedDate is allocated, or should I generate the 'number' in A5V11 and store it in the table? If in A5 where?

    Any pointers greatly appreciated.

    This is all new to me, so I'm keen to try and maximise effort and time spent chasing the solution. Can anyone advise me which end to start?
    Last edited by Malcolm; 09-18-2013, 05:49 AM. Reason: layout

    #2
    Re: sequential numbering - should I start in Access backend or A5

    It should be easy enough to increment the number in Alpha.
    Could you explain the numbering more clearly please?
    Like which bits are unique, which are incremental.
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    Comment


      #3
      Re: sequential numbering - should I start in Access backend or A5

      You seem to be on the right track, and I would agree with Ted.

      You need (and probably have) these tables:
      Branches (BranchID - autoinc, BranchName - char)
      Projects (ProjectID - autoinc, BranchID - long integer, ProjectYear - integer, ProjectSerial - integer, ProjectName - char, ApprovedDate - date)

      I would then create a left join Query view in Access that shows all the project table fields as well as the BranchName and maybe a field called ProjectCode (a string that combines the ProjectYear and ProjectSerial. e.g. '3/13'). This query view would then be used in your grid or dialog instead of the actual table.

      In general, I let Access generate auto-incremented ID numbers where ever possible - as in the first table's BranchID and the second table's ProjectID. But it would make sense to let ProjectCode hold your unique calculated string like '3/13'. Your xbasic code could insert the correct year and serial numbers at the time of insert (by first querying the Projects table for the largest branch serial + 1).

      If possible, could you change the project code to '13-03' instead? This would allow easier grid sorting in future.

      Good luck.

      Comment


        #4
        Re: sequential numbering - should I start in Access backend or A5

        Thanks both for your responses. a couple of points of clarification please?

        "I would then create a left join Query view in Access that shows all the project table fields as well as the BranchName and maybe a field called ProjectCode (a string that combines the ProjectYear and ProjectSerial. e.g. '3/13'). This query view would then be used in your grid or dialog instead of the actual table."

        It looks good until here - and if I understand it correctly Access grabs the year (e.g.13) from the ApprovedDate, and the ProjectSerial from the 'largest branch plus 1' and combines them as 13-03 (another great suggestion, thanks). This means that as soon as the user saves an ApprovedDate, the ProjectSerial is calculated and inserted into that field by Access. Access does everything. Makes a lot more sense than other solutions I've read about.

        Isn't this all that's needed then? Why would xbasic need to insert the correct year and serial numbers at the time of insert - if they're already being calculated by Access and inserted - or have I misunderstood something?

        Comment


          #5
          Re: sequential numbering - should I start in Access backend or A5

          Hey Malcolm,
          First, I recommend that you should use the grid to display the list, but use a dialog to add/update or delete each individual entry.
          Don't let Access calculate the year or the serial. However, in your DB, once your ProjectID is PK and autonum, and your combined Year (like 2013) & Serial (like 25) is defined as a unique index, then you are safe in knowing that you can't duplicate the job entry.
          You can then set up your dialog component to allow manually entering both the year and serial into separate text boxes. You can set up the server-side logic so that if these are blank, then (in afterDialogValidate) you can calcualte the current year, then (if also blank) query the DB to get the latest serail for that year, and replace the blank values with the current year and the next available serial as needed. This allows the same dialog to be used for new entries and existing edits.
          The dialog is therefore simply a manual entry/edit "form" for the database table, but with some logic to figure out the current year and latest serial as needed.

          Comment


            #6
            Re: sequential numbering - should I start in Access backend or A5

            Thanks Andy - I've got Access set up as you describe, now to get on top of the xbasic. At least I know which direction to head now. Thanks for the direction. Malcolm

            Comment


              #7
              Re: sequential numbering - should I start in Access backend or A5

              OK Andy, if you're still there, this is what I've come up with:

              My Access backend query now has the following (relevant) fields:

              CaseID(PK), BranchID, ProjectSerial(this is a number incremented by each branch as above), ProjectYear(e.g.13 for 2013), ProjectCode(blank at present but ready to receive ProjectYear and ProjectSerial as 13-6 - for the sixth project for that branch in 2013)

              From your guide above, what I think should happen next is that Alpha gets to concatenate ProjectYear (eg 13) and ProjectSerial(eg 6) into ProjectCode (eg 13-6) as the user saves a Project where the ApprovedDate is not null.

              I'm only using a grid (as opposed to a dialog), so could you explain how and where I get to set up the server-side logic so that the afterDialogValidate) function can do this? I'm not sure if I'm understanding this correctly.

              Many thanks - again

              Comment


                #8
                Re: sequential numbering - should I start in Access backend or A5

                Hey Malcolm,
                Your proposed fields are duplicating information. I think you should either leave out the ProjectCode field (instead concatenate it like yy-sss in your Select queries when you wish to display the project code), or leave out the ProjectYear and ProjectSerial fields. This choice is up to you, but I prefer the first option.
                Then, when you add a new record, don't use the DB's autoincrement, instead calculate the year and serial in xbasic by querying the DB, getting the MAX serial for the particular branch/year combo, and adding 1.

                You'll need to have a look at some of the videos from v10.5 - you'll see some examples of xbasic events for beforeSQL commands.
                http://news.alphasoftware.com/v11preview/videos_v11.htm

                But I much prefer using dialogs for this type of thing and don't use the grid for editing anymore.

                Andy.

                Comment


                  #9
                  Re: sequential numbering - should I start in Access backend or A5

                  Thanks Andy, Thanks for drawing my attention to that set of vids - I had overlooked them before.

                  Comment

                  Working...
                  X