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

xbasic way to turn-on or turn-off field rules?

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

    xbasic way to turn-on or turn-off field rules?

    Hi,

    I'm looking for a way to turn off a field rule from a form.

    I have a form with a field rule set to "previous values". Sometimes this option makes entry more difficult.

    I'd like a way for a user to select "previous values" or "Not" from the form.

    Are there other ways other than field rules to enable or disable this feature.

    Thanks

    Tom

    #2
    RE: xbasic way to turn-on or turn-off field rules?

    Tom,

    A field rule could be written, for a calculated field, which referred to a function. The function could have tests for certain criteria, branch on the tesult of the test, and lookup values, require user input (ui_get...), etc.

    Could this do what you want?
    There can be only one.

    Comment


      #3
      RE: xbasic way to turn-on or turn-off field rules?

      I have been exploring moving AWAY from field rules for similar reasons. Field rules are great for speed and universal application, but as I get more specific in my desire for control I am using xbasic in table and form events instead. Just because Alpha Five is fast, and can do lots without programming does not mean you only work this way. I have several lookups from arrays etc.

      I love the previous values rule, but don't know how it could be conditionally managed... Maybe Stan's function idea, but that will still not use the previous value lookup.

      I seem to remember an article on Dr Waynes site that pertained to speed fill of data. It captured every key press and responded appropriately. I shied away then, but might look at it now as I am more comfortable with the xbasic.

      Comment


        #4
        RE: xbasic way to turn-on or turn-off field rules?

        Thanks Stan and Steve for your input.

        I also recall Dr. Wayne's script, I'll take a look at it. I also recall he said he never uses field rules, but rather creates his own.

        So the question becomes, how does one program a lookup on previous fields? I imagine the code would go on the onarrive event of the field. This code would first check to see if the box was checked to enable or disable, this event.

        An array would not work since there would be alot of duplicate fields.

        I'll look for Dr. Wayne's code.

        Other suggestions, or approaches?

        Tom

        Comment


          #5
          RE: xbasic way to turn-on or turn-off field rules?

          Thomas -
          you can fill an array with the unique values. But it all depends on your situation. Is the table large or small, are there a lot of different values to lookup, do you want to restrict the range of choices. If the table is large you might create a special table just to hold the unique values. Add them as they come, look them up as you need. Or index on the field with the unique option so a script can fill an array without too much delay. This is where Alpha Five is not helpful - there are so many choices and alternatives, and there is no right way, just better ways.

          Comment


            #6
            RE: xbasic way to turn-on or turn-off field rules?

            Hello Tom,

            Your field rules lookup can be a conditional table lookup. You might make the lookup conditional on the value of another field for instance.

            As for programming your own, I'd think an array would be the way to go. Only other way I can think of would be to populate a dummy table and lookup to that, but nothing gained here. You'd populate the array from unique values only, not all values.

            Good luck,
            Jim

            Comment


              #7
              RE: xbasic way to turn-on or turn-off field rules?

              I haven't worked out all the details but this should get you started:

              - Set a global variable that will determine if the 'previous value' should be used.
              - Go to the CanEditField event in the table's field rules.
              - Start with:
              IF table.current().mode_get() 2
              END
              END IF
              This stops the script if the current record is not in the ENTER mode.
              - Now get the value that you want to put in the field by using one of the "lookupx()" functions. HINT: use the "L" match type to find the last matching record in the index. (Don't use the plain Lookup() function because it doesn't use an index and can take a long time.)
              - Put the value in the field. (Getting it to display might be an issue but I'll let you try it first. I know I've done it before; I just don't remember how. Maybe with A_field_value??)

              Comment


                #8
                RE: xbasic way to turn-on or turn-off field rules?

                Thanks Steve, Jim and Cal -

                Steve - I wasn't aware you could filter an array. Is it possible.

                Jim - I like your solution. I'll give it a try. Should be easy and direct.

                Cal - I'll add your suggestion to test for enter mode. But lookupL() only brings back one value, correct? I want a list of values to choose from.

                Thanks for all your help.

                Tom

                Comment


                  #9
                  RE: xbasic way to turn-on or turn-off field rules?

                  I guess I didn't read it carefully enough. I was think about a default lookup to the previous value when creating a new record rather than a lookup field rule. I thought that sounded like a simple question for someone who's been a regular on this board for so long. (Of course, I never ask simple questions. The time many years ago when I couldn't remember how to spell "got" was just a fluke.)

                  Comment


                    #10
                    RE: xbasic way to turn-on or turn-off field rules?

                    Thomas - you don't filter the Array - you fill it with filtered data. Either have an index or run a query to get the unique values, then get the number of records (to dimension the array), then fill it. If the tables have thousands of records it may get slow, and it may be smoother to post unique values to another table during data entry, and then use THAT table as a lookup for field values.

                    Comment


                      #11
                      RE: xbasic way to turn-on or turn-off field rules?

                      Stephen,

                      I'm using your latter method, and its working fine. The problem with previous values is that you cannot replace a previous value. I'm entering medications, and if I once enter TYlenol instead of Tylenol, I cannot fix the capitolization without changing the field rules, then correcting the item.

                      Now about filtering data before filling an array. I'm anxious to give this a try. I'll define my index (unique), then in set this index, then add the array script. Correct?

                      I'm on my way to try it.

                      Tom

                      Comment


                        #12
                        RE: xbasic way to turn-on or turn-off field rules?

                        Works great.

                        I thought I'd have to wait for V5 for this feature. One less reason to need V5. We users may create version 5 features before it is released! ASC may find they cannot compete with their users for new features.

                        Thanks again,

                        Tom

                        Comment


                          #13
                          RE: xbasic way to turn-on or turn-off field rules?

                          Thomas - here's a script on a button that uses an array for lookup. Might give you some ideas.

                          ''XBasic
                          dim pickcrew as c 'variable for current choice
                          dim shared lastcrewchoice as c ' variable, to remember the last choice
                          ctbl = table.open("Crew") 'open the table I use for lookups
                          cindx = ctbl.index_primary_put("Crew") "Crew index is unique
                          num = cindx.records_get() 'see how many records in the index
                          num = num + 1 'I add one, to give room for an "All crews" option
                          ctbl.Fetch_First() 'go to top of crew table
                          dim clist[num] as C 'dimension the array
                          clist[1] = " All Crews" 'add the All Crews option
                          i = 2
                          while i ""
                          while clist[i] lastcrewchoice .AND. iCrew = pickcrew 'this relates to my form
                          :Schedule:Crew.Refresh()'refresh the form
                          if alltrim(Substr(pickcrew,1,6)) = "" 'create the approriate filter
                          filter = ""
                          else
                          filter = "CREW = '" + alltrim(Substr(pickcrew,1,6)) + "'"
                          end if
                          '*****Run the query to show the selected info
                          topparent:tables:sched.filter_expression = filter
                          topparent:tables:sched.order_expression = "str(Seq)+Job"
                          topparent:tables:sched.query()

                          Comment

                          Working...
                          X