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



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 to get the auto increment ID?

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get the auto increment ID?

    I have 2 tables:
    -- Transaction
    -- Transaction Detail

    The Scenario:
    Invoice is sent to customer
    Customer submits payment for invoice
    Payment is posted to Invoice and completes that invoice
    Payment is also written to "Undeposited Funds" account transaction
    Now ...

    I display a browse showing undeposited funds and use the "mark" functionality to select the records to be deposited.
    The system totals the amounts selected.
    I choose the bank account that I want to post the deposit to.
    A Deposit transaction is written to that bank account.

    And here's the snag -
    I want to write the transaction detail (which payments were selected to make this deposit?) to the transaction detail table so that I see something like this:

    The transaction:
    011294 101 12/24/2009 Deposit $400

    Transaction Detail:
    011294 1 CustomerA $100
    011294 2 CustomerB $100
    011294 3 CustomerC $200

    The TRANS# is auto-incremented at the parent level and if I were to manually enter a transaction, gets automatically created on the child record. But I am not manually entering transactions here, these are processed when an OK button is pressed.

    You guys have convinced me that I over complicate things; so I am trying to use scripts and operations vs. xbasic.

    The question -
    How do I get that (unknown) TRANS# from the parent to the child? Or shall I just use a known value to link to the transaction detail (ie. Job#)?

  • #2
    Re: How to get the auto increment ID?

    Here I am answering myself again ... I have an idea - and in fact, have used it in the past but will have to work through it. Cannot get my mind to quit thinking "For each" (as in Progress) ...

    Here's the plan ...

    Detail information is known
    Header information is not known

    So - create the detail records with a unique id
    Summarize those newly created records and create a header with a unique id
    Using the unique id just created for the header, modify the detail record to include that id.

    I think .. does this sound logical?


    • #3
      Re: How to get the auto increment ID?

      Betty, it is logical but to my way of thinking a tad convoluted.

      How were you planning to enter the "header" information into the "Transaction" table for the deposit transaction? i.e. what would your script look like? what technique were you thinking of using to do this?


      • #4
        Re: How to get the auto increment ID?

        You can easily create the header first, and then the details. Let's say the header's autoincrement field is "id" (for simplicity).

        Then you can write a script

        dim hdr as"header")

        header_id =
        This gives you the unique autoincrement ID for the header record you have just created. You can then insert that into the detail records.


        • #5
          Re: How to get the auto increment ID?

          To use the actual example you provided:

          ' I don't know how you get the details, whether a list or an 
          ' array. I chose a list here, it could as easily be an array.
          trans=hdr.trans   ' autoincrement field
          for each rec in detailRecs
          ' now, update the Amount field in header table


          • #6
            Re: How to get the auto increment ID?

            That looks way simpler than I was thinking ... will try it. Thank you.


            • #7
              Re: How to get the auto increment ID?

              I like the "for each" statement. Your code looks a lot more like I am used to than some other samples I've seen; almost 4GL.


              • #8
                Re: How to get the auto increment ID?

                This works - and works well. but -

                "Trans_num" is a character field in both the parent and child table. In the xbasic code, it is defined as a character field. When I display it using a msgbox before running the append, it looks like a character value. When I run the append code, I get this error:
                "Field and Expression Types must match".

                Here's the code (I added msgbox to see what it is doing)

                dim shared varC_trans as C

                'create header record
                varC_trans=hdr.trans_num ' autoincrement field

                -- I see a character value here with no decimals "01200"

                a_tbl ="acct_trans_detail")
                append.t_db = "c:\a5db\bbw\undeposited_funds.DBF"
                append.m_key = ""
                append.t_key = "recno()"
                append.m_filter = ""
                append.t_filter = "marked()"
                append.type = "All"
                append.m_count = 3
                append.m_field1 = "Trans_Num"
                append.m_exp1 = varC_Trans
                -- if I changed this to "str(varC_Trans)" it writes to the transaction detail table but I see 2 decimals as in "01200.00"

                append.m_field2 = "Reference"
                append.m_exp2 = "@Undeposited_Funds->Reference"
                append.m_field3 = "List_Price"
                append.m_exp3 = "@Undeposited_Funds->Amount_Paid"
                append.t_count = 1
                append.t_case1 = "APPENDED"
                append.t_field1 = "@Undeposited_Funds->Posted"
                append.t_exp1 = ".T."


                • #9
                  Re: How to get the auto increment ID?

                  Perhaps having a second set of eyes look things over would help? Why not zip a sample of the database and post it here, with instructions for us to follow to repeat your sequence?


                  • #10
                    Re: How to get the auto increment ID?

                    Created a new field with a different name on the child table and blew the old field away. Works. No change to the code.


                    • #11
                      Re: How to get the auto increment ID?

                      Happy XMas to you Tom Cone. Thank you.


                      • #12
                        Re: How to get the auto increment ID?

                        Hey, that's good news. Glad you got it going. Merry Christmas!