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

Inserting data

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

    #16
    Re: Inserting data

    Sorry Gregg, didn't manage to get how your code work. But I tried the following.

    dim shared vFamid as C
    dim vFIDLast as C
    dim vCFID as C

    vFamid = "C00001"
    vFIDLast = tablemax("biocustomer","customerid = "+s_quote(vfamid),"customerid")
    vCFID = increment_value(vFIDlast)


    The result I got was vCFID="C00002" instead of "C00004", where did I go wrong?


    Before.jpg
    After.jpg

    Comment


      #17
      Re: Inserting data

      Nice job finding the increment_value() function.
      Looks like you changed to dbfs from sql.
      Try this code.
      Code:
      vFamid = "C"
      vFIDLast = tablemax("biocustomer","left(customerid,1) = "+s_quote(vfamid),"customerid") 
      vCFID = increment_value(vFIDlast)
      Gregg
      https://paiza.io is a great site to test and share sql code

      Comment


        #18
        Re: Inserting data

        While you can use the customer table/index method, it does have holes in it.

        1. It relies on an index based on the customer table. If the index become corrupted, multiple issues can happen - ie wrong values assigned, orphaned child records.

        2. Having used this method and the control table method, I still use the control table. A little more work, but much less likely to fail.

        3. No method is perfect. At least not in this life. Some are more solid than others. Choose wisely.
        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


          #19
          Re: Inserting data

          Originally posted by madtowng View Post
          Nice job finding the increment_value() function.
          Looks like you changed to dbfs from sql.
          Try this code.
          Code:
          vFamid = "C"
          vFIDLast = tablemax("biocustomer","left(customerid,1) = "+s_quote(vfamid),"customerid") 
          vCFID = increment_value(vFIDlast)
          Thanks Gregg, it work perfectly but now it get a bit complex. I noticed there are same Customer ID but with different Branch code. If the customer is from Branch code "AMK", the next ID should be "C00003" but it display "C00004" instead. How can I add a filter that only select the last record from certain Branch code?


          Before01.jpg
          Last edited by samt2046; 10-02-2019, 01:08 AM.

          Comment


            #20
            Re: Inserting data

            Originally posted by Al Buchholz View Post
            While you can use the customer table/index method, it does have holes in it.

            1. It relies on an index based on the customer table. If the index become corrupted, multiple issues can happen - ie wrong values assigned, orphaned child records.

            2. Having used this method and the control table method, I still use the control table. A little more work, but much less likely to fail.

            3. No method is perfect. At least not in this life. Some are more solid than others. Choose wisely.

            Thanks Alan, this will be my last resort if I cannot find other solutions.

            Comment


              #21
              Re: Inserting data

              ok...try this
              Code:
              vFamid = "C"
              vBranch = "AMK"
              vFIDLast = tablemax("biocustomer","branch=vBranch .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid") 
              vCFID = increment_value(vFIDlast)
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #22
                Re: Inserting data

                Originally posted by madtowng View Post
                ok...try this
                Code:
                vFamid = "C"
                vBranch = "AMK"
                vFIDLast = tablemax("biocustomer","branch=vBranch .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid") 
                vCFID = increment_value(vFIDlast)
                I have tried but got the error "Variable type mismatch: Cannot assign data of Type"

                Comment


                  #23
                  Re: Inserting data

                  vFamid = "C"
                  vBranch = "AMK"
                  vFIDLast = tablemax("biocustomer","branch=vBranch .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid")
                  vCFID = increment_value(vFIDlast)
                  It probably cannot resolve vBranch,

                  try

                  vFIDLast = tablemax("biocustomer","branch=s_quote(vBranch) .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid")

                  Tom

                  Comment


                    #24
                    Re: Inserting data

                    Originally posted by Tom Henkel View Post
                    It probably cannot resolve vBranch,

                    try

                    vFIDLast = tablemax("biocustomer","branch=s_quote(vBranch) .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid")

                    Tom
                    Hi Tom, still having the same error, I wonder where went wrong, I even tried.

                    vFIDLast = tablemax("biocustomer","branch=val->vBranch .and. left(customerid,1) = "+s_quote(vfamid) ,"customerid")

                    Cheers

                    Comment


                      #25
                      Re: Inserting data

                      shouldn't this be
                      Code:
                      vFIDLast = tablemax("biocustomer","branch = " + s_quote(vBranch) + " .and. left(customerid,1) = " + s_quote(vfamid) ,"customerid")

                      Comment


                        #26
                        Re: Inserting data

                        My bad...


                        code should be:
                        "branch="+s_quote(vBranch)+" .and.

                        because I had the "S_quote(vBranch)" within the quotes, the filter interpreted it as text, not a function.

                        sorry

                        Comment


                          #27
                          Re: Inserting data

                          Part of the reason I stopped using dbfs is because the filters aren't as intuitive as with sql.
                          Now that I realize this, I'm going to offer my preferred solution.

                          This allows me to easily see what the filter looks like ie: branch = "AMK" .and. left(customerid,1) = "C"
                          luFilter does not need to be a pointer variable, but I often use several different lookups (or sql queries) and
                          this allows me to alter the original in a loop, yet not have to redefine from scratch each time.

                          Finally, if it doesn't work, please post the actual code you are using.
                          Ideally , provide some sanitized data for each table (in text so we can use it to create the tables).


                          Code:
                          dim vFamid as c
                          dim vBranch as c
                          dim luFilter[0] as p
                          luFilter[].original = <<%txt%
                          branch = "<vBranch>" .and. left(customerid,1) = "<vfamid>"
                          %txt%
                          
                          vFamid = "C"
                          vBranch = "AMK"
                          luFilter[1].altered = strtran(luFilter[1].original,"<vBranch>",vBranch)
                          luFilter[1].altered = strtran(luFilter[1].altered,"<vfamid>",vFamid)
                          debug(1)
                          vFIDLast = tablemax("biocustomer",luFilter[1].altered ,"customerid") 
                          vCFID = increment_value(vFIDlast)
                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #28
                            Re: Inserting data

                            A big thanks to Tom and Gregg, both solutions works perfectly. Thanks again for all the help from all of you.

                            Cheers

                            Comment


                              #29
                              Re: Inserting data

                              Hi guys, I hit another brick wall.....I didn't realize the database was created in such way. I have just found out that there are extra character for some customer in the customer ID. From the image, if I want to find out the last ID for "G", it will go to the last record of "GE" instead. Prefix for GE is reserved for Guest only. I have try Fetch_Prev() but it only return the number "1031". Following is my code.

                              vFamID = left(dbxLname,1)
                              msgbox("Customer_ID",vfamid)

                              if substr(vFamID,1,1) = "G"
                              vFamID = "GE"
                              dim luFilter[0] as p
                              luFilter[].original = <<%txt%
                              branchcode = "<vBranch>" .and. left(customerid,2) = "<vfamid>" %txt%
                              luFilter[1].altered = strtran(luFilter[1].original,"<vBranch>",vBranch)
                              luFilter[1].altered = strtran(luFilter[1].altered,"<vfamid>",vFamid)
                              vFIDFirst = tablemin("biocustomer",luFilter[1].altered ,"customerid")
                              msgbox("First FID",vFIDFirst)

                              dim tbl as P
                              tbl = table.current()
                              tbl.index_primary_put("customerid")
                              tbl.fetch_find("vfidfirst")
                              vvfamid = tbl.fetch_prev()
                              'msgbox("Previous",vvFamid)
                              vCFID = increment_value(vvFamid)
                              'msgbox("Next FID", vCFID)
                              goto CONT1
                              end if



                              Extra.jpg

                              Comment


                                #30
                                Re: Inserting data

                                You have a lot more going on than you did before.
                                I commented out several lines with ''' to test the code.
                                This is quite different than what we had as you are now using tablemin() instead of tablemax() (is this a separate module?).
                                The real changes I made (they should even work with the original code) should even work with the previous solution.

                                Code:
                                '''vFamID = left(dbxLname,1)
                                '''msgbox("Customer_ID",vfamid)
                                debug(1)
                                vFamID = "G"
                                'I added the vBranch to make the code work
                                vBranch = "AMK"
                                dim luFilter[0] as p
                                ' My changes begin here
                                luFilter[].original = <<%txt%
                                branchcode = "<vBranch>" .and. left(customerid,2) = "<vfamid>" .and. left(customerid,2) <> "GE" 
                                %txt%
                                luFilter[].original = <<%txt%
                                branchcode = "<vBranch>" .and. left(customerid,2) = "GE"  
                                %txt%
                                select
                                	case left(vFamID,2) = "GE"
                                		luFilter[2].altered = strtran(luFilter[2].original,"<vBranch>",vBranch)
                                		luFilter[2].altered = strtran(luFilter[2].altered,"<vfamid>",vFamid)			 
                                	case else
                                		luFilter[1].altered = strtran(luFilter[1].original,"<vBranch>",vBranch)
                                		luFilter[1].altered = strtran(luFilter[1].altered,"<vfamid>",vFamid)		
                                end select
                                'my changes end here
                                vFIDFirst = tablemin("biocustomer",luFilter[1].altered ,"customerid") 
                                msgbox("First FID",vFIDFirst)
                                
                                dim tbl as P
                                tbl = table.current()
                                tbl.index_primary_put("customerid")
                                tbl.fetch_find("vfidfirst")
                                vvfamid = tbl.fetch_prev()
                                'msgbox("Previous",vvFamid)
                                vCFID = increment_value(vvFamid)
                                'msgbox("Next FID", vCFID)
                                '''goto CONT1
                                Gregg
                                https://paiza.io is a great site to test and share sql code

                                Comment

                                Working...
                                X