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

Help with Tablemax function

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

    Help with Tablemax function

    I am using the 30 day trial of Alpha Five V9 Platinum to link to an Access table, so far so good!

    One of the fields in this table Contains Job Numbers (which is a string)

    JOB_NO
    12345
    23456
    R23457

    etc..

    I am trying to use the Tablemax command to find the greatest value stored in this field (I want to filter out any JOB_No's that start with an R) this is the code I have tried:

    dim OJN as c
    OJN = tablemax("acc_orders.dbf", "left(JOB_NO,1)<>\"R\"", "JOB_NO")

    but I get the following error (see tablemax.jpg), I have tried various different ways of doing the above but I still can't get it to work, is there an easier way or can anyone suggest what the problem is?

    #2
    Re: Help with Tablemax function

    In the interactive editor try

    ? tablemax("acc_orders.dbf", ".T.", "JOB_NO")

    to see what the result is. That should help diagnose what is going on here.
    There can be only one.

    Comment


      #3
      Re: Help with Tablemax function

      Hi Stan,

      Interestingly, I get the same error, when run from the pushbutton on the form.

      When I run it from the interactive editor, I get the following message:

      = <No data returned>

      However, it works if I use the same code on a native alpha five table!

      Does this command not work with an active link table?
      Last edited by Alastair; 08-18-2008, 11:48 AM. Reason: Extra info. added

      Comment


        #4
        Re: Help with Tablemax function

        Hi Alastair,

        Have you tried to use Arguments, this is where you can filter the data that gets returned from the data source.

        The active link table is only a link to the data, it does not hold any data.

        Following our chat, I have attached a thumbnail of records selected from the Alphasports.mdf table. I asked for only records where the last name was between the Start argument and the Last argument. I also asked for the Order to be on the LastName.

        I hope this explains better how the Active link table works.
        Regards
        Keith Hubert
        Alpha Guild Member
        London.
        KHDB Management Systems
        Skype = keith.hubert


        For your day-to-day Needs, you Need an Alpha Database!

        Comment


          #5
          Re: Help with Tablemax function

          Hi Keith,

          I took your advice and downloaded the new version, I must say I like some of the improvements I have seen so far very much!

          I have only had the new version on my PC at work for a few hours so haven't seen arguments yet, I will have to look into these and see if they will do what I need.

          The Job No data is a bit more complicated than I first thought! I couldn't remember how I had set up the old Access database, it seems Job No field consists of a 6 long char which contains the following prefixes:

          12345 = Job No
          R12345 = Quote
          MW2345= ?? Entered by another user
          A12345 = ?? Entered by another user

          All I want to do is to find the max. of the valid Job Nos. e.g. ones without a letter prefix and add one to this number to calculate the new Job No. I will have to filter out all the Job Nos starting with a letter and then find the max. of the remaining results. Does this sound like a task for Arguments?

          Comment


            #6
            Re: Help with Tablemax function

            Hi Alastair,

            This sounds like you have got a real problem on your hands.

            The field that holds the Job No should be just that. The status of the Job "R" should be in a separate field. The prefix of the of who the user was should also be in a separate field. These fields can all be concatenated for viewing.

            With the data in your access app in separate fields then you can use the active link to call the records you want.

            I cant see how you can do what you want, with the way the data is structured.
            Regards
            Keith Hubert
            Alpha Guild Member
            London.
            KHDB Management Systems
            Skype = keith.hubert


            For your day-to-day Needs, you Need an Alpha Database!

            Comment


              #7
              Re: Help with Tablemax function

              Hi Keith,

              It is possible to filter them out! I wrote some code (along with a query table)to do it in Access a long time ago.

              There is a reason for the two main different categories of Job No in the Access db. It was based on the old method of entering orders into a book (believe it or not) and my boss at the time wanted to keep the same system. I don't think this is ever likely to change.

              The Access db was setup like this

              Job No, Char, 6
              Quote No, Char, 6

              With Job No being the key field (indexed). However a job could be entered as a quote or a job and when the client accepted the quote, the quote then became a job. I got around this by making the Job No field = Quote No field while the job was at quote stage. When the quote became a job, the quote no in the Job no field was replaced by a proper job no - more difficult to explain than to program!

              At quote stage:

              I have two pushbuttons on the form next to these fields one called Auto Quote No the other Auto Job No so initially if we are quoting a Job we press the Auto Quote No button which fills Job No and Quote No with the next valid Quote No e.g.

              Job No = "R1234"
              Quote No = "R1234"

              If the client accepts the quote the value in the Job No which is actually the Quote No is overwritten by the next Job No (by pressing the Auto Job No button, so assuming previous Job No was "2344"

              Job No = "2345"
              Quote No = "R1234" (provides cross ref. to original quote)

              If the client placed an order direct the quote no was left blank (we just press the Auto Job No button)

              Job No = "2345"
              Quote No = ""

              It looks messy but it works fine. Unfortunately, some other users have added prefixes of their own manually! It also does mean that the Job No has to be filtered to obtain the results I require.

              I am sure if its possible in Access then Alpha must be able to do it. I was after a neat solution and tablemax seemed ideal! I thought the whole idea of having active link tables was so we could read the data from an original db, manipulate it and then use Alpha 5 to write it back to the original db, if we wanted?
              Last edited by Alastair; 08-18-2008, 07:49 PM.

              Comment


                #8
                Re: Help with Tablemax function

                Alastair,

                This might work for you....use txt=table.external_record_content_get() to obtain the crlf list from your table. Check out the help file for the needed arguments for this function.

                http://support.alphasoftware.com/alp...TENT_GET().htm

                The following simply takes a crlf list, removes any records that have any of the characters in the exclude list (x_lst), then finds the largest record.


                Code:
                dim lst as c
                lst=""
                dim txt as C
                txt=""
                dim x_lst as c
                
                ''''''I used the linear comma list simply to reduce amount of script on the page with it then
                ''''''  converted to a crlf afterwards
                x_lst=<<%a%
                A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z
                %a%
                x_lst=comma_to_crlf(x_lst)
                txt=<<%list%
                12345
                R12345
                MW2345
                A12345
                12346
                12348
                %list%
                
                
                lst= filter_string_multi(txt,x_lst,chr(13)+chr(10),.t.)
                
                ?lst
                = 12345
                12346
                12348
                ? *max(lst)
                = 12348
                Last edited by MikeC; 08-19-2008, 01:34 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


                  #9
                  Re: Help with Tablemax function

                  Hi Mike,

                  Thanks for the advice, I will take a look at that command.

                  Comment


                    #10
                    Re: Help with Tablemax function

                    Perhaps, this can help.

                    I use the follow function:
                    Code:
                    FUNCTION UpdGim AS C (xField AS C )
                    
                    dim xgim as P 
                    dim xNext as N 
                    
                    xgim=table.open("gim")
                    
                    ON ERROR GOTO error_handler
                    commit_flag = .t.
                    xgim.change_begin()
                    xNext = eval("xgim." + xField) + 1 
                    eval("xgim." + xField) = xNext
                    xgim.change_end(commit_flag)
                    
                    UpdGim=xNext
                    
                    END FUNCTION
                    
                    error_handler:
                    commit_flag = .F.
                    RESUME NEXT
                    GIM is a Table with a field for every counter (i.e. documents), so you only have to synchronize ONCE the GIM with your transaction table and then call this function to get the new "max".
                    by the way, GIM works fine on dbf and on active links tables.


                    Originally posted by Alastair View Post
                    Hi Mike,

                    Thanks for the advice, I will take a look at that command.

                    Comment


                      #11
                      Re: Help with Tablemax function

                      Hi Angel,

                      Thanks for your reply and the function, however I don't understand the code at all! Can you provide some instruction on how I should use it?

                      Thanks,

                      Alastair

                      Comment


                        #12
                        Re: Help with Tablemax function

                        Hi there Alastair,

                        Gim is a table with only one record, but many numeric fields. One field per counter. So, you have to create a GIM Table with one record and one field at least, a field for your counter.

                        GIM
                        JOB_NO,N,10,0

                        You must start JOB_NO with your real max, only this time.

                        When you need to INSERT a new record with the next number in JOB_NO, you would not need to search it in your transaction table, just call the function, Like this:

                        newJOB_NO=UpdGIM("JOB_NO")

                        Luke!


                        Originally posted by Alastair View Post
                        Hi Angel,

                        Thanks for your reply and the function, however I don't understand the code at all! Can you provide some instruction on how I should use it?

                        Thanks,

                        Alastair

                        Comment


                          #13
                          Re: Help with Tablemax function

                          Hi Luke,

                          Thanks for your reply, but now I understand how your code works, I don't think it will work for me on this problem.

                          The active link table I am trying to set up is to read in a live value for Job No from an Access database, which is still in use. The Job No is being updated regularly in Access by other users during the day and I need the up to date live value of Job No copying from the Access db to the Alpha db.

                          Is setting up an active link table the right way to go about this or has anyone got a better idea?

                          Comment

                          Working...
                          X