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

how can I set up two independent incremental fields?

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

    how can I set up two independent incremental fields?

    I have one form for logging two types of bookings. Boat rentals and Seamanship courses.

    I need two series of reference (booking) numbers, one for rentals R0001 and one for courses C0001.
    The problem is that I cannot simply make them both (using field rules) incremental, since a rental booking, will not only increment R0001, but will also increment C0001, and vice versa.

    If there were (for example)11 records, 4 rentals, and 7 courses, then I need the ref. nos. to read R004 and C007 respectively.


    I am trying to keep it simple, but I cannot see an obvious solution.

    If anyone could give me a clue or two, I would be grateful.

    brianp

    #2
    Re: how can I set up two independant incremental fields?

    Instead of using autoincrement, I used default expressions. See the attached sample BOOKINGS database.

    Comment


      #3
      Re: how can I set up two independant incremental fields?

      Gary,

      I really appreciate the help, but I am missing the point I am sorry to say.
      Am I looking for a 'default' value? possibly set to 'default+1 if 'C' (or 'R') is true?

      May have to blame it on advancing age (mine) but if you could expand on it a little.
      brianp

      Comment


        #4
        Re: how can I set up two independant incremental fields?

        Yes, it's a default expression. Open the BOOKINGS database in the zip file and look at the field rule default expression for the COURSE and RENTAL fields. To test it out, you can enter a few C and R records and see how it works.

        Comment


          #5
          Re: how can I set up two independant incremental fields?

          Gary,
          Never occurred to me to set it up with a default expression. Perhaps the obvious route.

          Whether a download/unzip problem or not I do not know, but there were not actually any field rules set on the unzipped table.

          I would be very interested to see the rule(s) though.

          I downloaded and unzipped on both my PC's, eith the same result.

          Either way, I appreciate the route marker.

          Brianp

          Comment


            #6
            Re: how can I set up two independant incremental fields?

            I'm attaching another zip file. It should contain the field rules (BOOKINGS.RLN) file.

            Comment


              #7
              Re: how can I set up two independant incremental fields?

              The default value for RENTAL is:
              IF(TYPE="C","","R"+RIGHT("0000"+LTRIM(STR(VAL(RIGHT(DBMAX"BOOKINGS.DBF","BOOKR","R","RENTAL"),4)))+1)),4))

              The default value for COURSE is:
              IF(TYPE="R","","C"+RIGHT("0000"+LTRIM(STR(VAL(RIGHT(DBMAX"BOOKINGS.DBF","BOOKC","C","COURSE"),4)))+1)),4))

              Comment


                #8
                Re: how can I set up two independant incremental fields?

                I have looked hard at your default value for both options, and whilst (so far), I can understand the basic functions, I don't think I will ever totally understand the whole thing.
                I cannot fully interpret the parameters of the DBMAX function, although I do appreciate the syntax.

                I have printed out each function, and will continue to battle with it.
                Frankly, I am amazed that anyone can compile it.

                I downloaded the second zip, and yes, the BOOKINGS.RLN file is there, nevertheless, when I look at the table field rules, there are not any.

                If I enter type as C or R, there is no autofill of any other field.
                That is weird.
                I copied and pasted the default values into default mode - simple default expression. but it gives me ERROR 1501.

                One thing, and I hesitate to mention it, but I notice there are six left brackets, but eight right brackets, and I cannot figure out how they work.

                Comment


                  #9
                  Re: how can I set up two independant incremental fields?

                  Brian,
                  I believe you are correct with the bracket difference. From what I can figure out the following is what it should be: Add the parenthesis in blue and take out the parenthesis in red

                  Code:
                  The default value for RENTAL is:
                  IF(TYPE="C","","R"+RIGHT("0000"+LTRIM(STR(VAL(RIGHT(DBMAX[COLOR="royalblue"]([/COLOR]"BOOKINGS.DBF","BOOKR","R","RENTAL"),4)))+1)[COLOR="Red"])[/COLOR],4))
                  
                  The default value for COURSE is:
                  IF(TYPE="R","","C"+RIGHT("0000"+LTRIM(STR(VAL(RIGHT(DBMAX[COLOR="RoyalBlue"]([/COLOR]"BOOKINGS.DBF","BOOKC","C","COURSE"),4)))+1)[COLOR="Red"])[/COLOR],4))

                  Try it and see.
                  Last edited by MikeC; 07-22-2007, 11:18 AM.
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: how can I set up two independant incremental fields?

                    If I may change the direction a bit - why do you need a different sequence for each? Can you live with one sequence 0001-n and then a single BookingType field that can be either C or R. You can concatenate those filelds if needed, adn they might apper in sequence like this: C0001, C0002, R0003, R0004, C0005, etc. If you someday add Events to your list, a booking for an Event might appear as E0099 and so on.

                    Why do all the C's need their own sequence separate from all the R's? You can still count all the C's or R's in a given time period, sort or filter by the BookingType, etc. Just the sequence of numbers for each individual type of booking will not be in perfect order, but does that matter? Maybe it isn't much but DBMAX will eventually cause performance problems as it counts every time you add a record.
                    Steve Wood
                    See my profile on IADN

                    Comment


                      #11
                      Re: how can I set up two independant incremental fields?

                      I agree with you Steve, "what does it matter".

                      It is only because the end user, wants to be able to split the two 'activities', on reports, and calender print-outs. Problem is, that I do see a certain logic in it. A report of all the rental bookingt over a given period, looks so much better to the VAT man, than if it has numerical gaps. That and the possibility of 'losing' a booking if there is not continuity of booking numbers.

                      To be honest, although I could not (can not) come up with what I really thought would be a relatively simple excercise, I still thought I was overlooking some obvious way to achieve this. I do not care for an "appelet" (is that correct?) to be counting or sifting through all the records every time a form is opened, but so often, I cannot find any other way.

                      Just to have multiple incremental fields, each incrementing only when it encounters a particular 'keyword' sounds, on the face of it, to be a very usefull tool. Wonder what the Alpha programmers might think.

                      Never sure if I should reply to all threads directly, but if I may . .

                      Comment


                        #12
                        Re: how can I set up two independant incremental fields?

                        Must have hit the wrong button, cont/

                        If I may . . Mike, I looked at your amendment, but although it does not bring up the error box, when I put in in the expression builder, it comes back with the 'usual' "invalid or incomplete expression"

                        I thank everybody, and I will accept all options and opinions gladly,

                        I will go back to the drawing board, but if the user is insistent (and I am sure he will be) I will pursue the 'default' route, I need the learning curve, and I have been given a clue or two, which will assist me greatly.

                        Regards

                        Brianp

                        Comment


                          #13
                          Re: how can I set up two independant incremental fields?

                          I want to clarify that my intent was to answer to riddle, not to question the database design. Your points are well taken.

                          Comment


                            #14
                            Re: how can I set up two independant incremental fields?

                            Originally posted by Gary Smith View Post
                            I want to clarify that my intent was to answer to riddle, not to question the database design. Your points are well taken.
                            Gary, I am most grateful for your suggestion(s), I am not aware that you did question the DB design, but you would have a perfect right to. Can't beat discussion to further experience, No, I was only replying to the thread added by Steve Wood, who also has a "right to reply".

                            I appreciate and respect the help available on the forum, and I am pleased for any ideas and comments, and I thank everyone for their input..

                            Comment

                            Working...
                            X