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

Field Events

  • Filter
  • Time
  • Show
Clear All
new posts

  • Field Events

    Hi All,

    I like to fire my scripts whenever I add New or changed a field value from the Form or Browse layout.
    Which action of the field or Record Events (Field Rules) is right one?

    Any of those events, How do you refresh form (or Browse) or Can I refresh only one object(a field which my script added the value)?

  • #2
    Re: Field Events

    Which action of the field or Record Events (Field Rules) is right one?
    There is no "right one". It depends on the situation. Field rule events may not even be the right events. Forms have events as well which may be better suited. More details are necessary.

    How do you refresh form (or Browse) or Can I refresh only one object(a field which my script added the value)?
    Probably want to resynch the form to the table to reflect the change.
    There can be only one.


    • #3
      Re: Field Events

      Jon, I do quite a bit of this as I have some complex refreshes etc.
      When you get more details Stan will certainly have the answer and I'll chip in too.
      See our Hybrid Option here;


      • #4
        Re: Field Events


        I think my coding (Write to table) is wrong because 1st record get the field value but 2nd record does not. I used the "OnWroteField" Rule.
        'Setp 1 - Current PriceBook 	
        	tPrcBk ="PriceBks")
        		vCurVndr = tPrcBk.Prdctvndr_id
        		vCurStart = tPrcBk.pbk_start_date
        'Setp 2 - Find Vendor Id from PrdctVndrs Table	    
        	tPrdVndr ="Prdctvndrs")
        	Query.filter ="prdctvndr_id="+quote(vCurVndr)
        	iPrdVndr = tPrdVndr.query_create("n",query.filter)
                      vPrdVndrId = tPrdVndr.Seriesvndr_id
        'Setp 3 - Find the Discount Rate from PriceDiscount table by vPrdVndrID and date
                        dim iPrcDisc as p
                        dim rPrcDisc as n
                        dim vDiscRate as n
        			    tPrcDisc ="PriceDiscount",FILE_RO_SHARED) 
        			    query.filter = "Seriesvndr_id ="+quote(vPrdVndrId)+".and. between("+s_quote(vCurStart)+",Startdate,enddate))" 
        	            iPrcDisc = tPrcDisc.query_create("n",Query.filter) 
        		        rPrcDisc = tPrcDisc.records_get()
        			        if (rPrcDisc>0) then
        			        	 vDiscRate = tPrcDisc.Discount_rate
        			             ui_msg_box("Record","No Discount Rate on this Vendor")	 
        			        end if	 
        'Write to table	 
                  tPrcBk.discount_rate = vDiscRate
        'Refresh a form
        ':browse6.refresh() 'Incorect Data Type
        'parent.browse6.refresh()   'Parent not found


        • #5
          Re: Field Events

          1st record get the field value but 2nd record does not
          The person doing the coding is responsible for moving the record pointer to the record(s) to which they want to write if it is not the current record. I can't tell from your code that you have queried PriceBks for any particular field value.

"PriceBks") is opening a new instance of PriceBks so the record pointer is likely on the first record when the code starts. (instead of using table.current(n) which would have you on the current record visible on the form)

          Whatever you decide to do with the table pointer you must wrap the write code in some loop to process more than one record like

          'Write to table	 
          while some logical test = .F.
                    tPrcBk.discount_rate = vDiscRate
          end while
          The suggested loop may not be exactly what you want in your situration. I can't tell.
          Last edited by Stan Mathews; 05-03-2010, 11:25 AM.
          There can be only one.


          • #6
            Re: Field Events


            What did you mean for "Some Logical Test" ?

            I can think about Mode_get() or <tbl>.fetch.

            I replaced with <tbl>.table_get(). I want to search and save a current record whenever I add or changed the field("start date") value.


            • #7
              Re: Field Events

              while .not. tbl_pointer.fetch_eof()

              while tbl_pointer.fieldname = some_value

              for example.
              There can be only one.


              • #8
                Re: Field Events

                Let's try it without all that code and stuff as Alpha inntended.
                John, what is it you need to do. Can you describe it please?
                See our Hybrid Option here;


                • #9
                  Re: Field Events

                  Hi Ted,

                  I want whenever Current browse value changed then look up a value from 3rd table and save to current table.


                  • #10
                    Re: Field Events

                    I could do with a little more tha that.
                    What is the application?
                    Why are you lookig up on a separate table?
                    What are you intending to write to the 3rd table?

                    On_Change will trigger your scripts, but beware changing in a Browse within a Form and expecting it to work as expected.

                    I'm on client site until the weekend, but will reply then.

                    See our Hybrid Option here;


                    • #11
                      Re: Field Events

                      I'll let Ted and others handle the basic question but I need to add this for anyone who thinks you need to use .Resynch()

                      (BTW, they're right - a better description of the what you want to accomplish is needed. Not a description of how you want to do it but what end result you want to accomplish. Now, back to my original thought...)

                      Do NOT use when working with a table related to a form or browse that should show the results of your change. That is the wrong thing to do! It's a bad thing! Don't do it unless nothing else works!

                      This is the voice of experience speaking. BTDT for many hair pulling years before I finally figured this out. Life is much more relaxed now. (At least in this one regard.)

                      Note that I did NOT say "Never use". I said "Don't use when working with a table related to a form or browse that should show the results of your change.

                      Stan's comment that, ""PriceBks") is opening a new instance of PriceBks so the record pointer is likely on the first record when the code starts" is absolutely correct but it needs to go a step further. Not only is it a "new instance" but the form you're working on has no idea what happens in that "new instance" so it becomes difficult to update the form - sometimes so difficult that the only solution is to close the form, re-open it, and find the original record. (I've actually done that in production applications in the past before I learned to use table.get().) However, if you get a pointer to the same instance of the table that the form is using by using Table.GET(), then you may not have to do anything to get the changes to show up in your layout - it often happens automatically or with a simple parentform.refresh_layout() - no .resynch() required.

                      Another advantage of table.get() when it points to a child table is that a .fetch_first() will take you to the first record that matches the current parent record and you can fetch through the child records until .fetch_eof() returns .T. when you try to fetch past the last child record.
                      Last edited by CALocklin; 05-07-2010, 12:00 AM.


                      • #12
                        Re: Field Events


                        My Script is working fine if it triggers on Form(Browse) events as Ted and Stan mentioned.

                        Here, as Ted asked me.
                        What is the application?
                        Why are you looking up on a separate table?
                        What are you intending to write to the 3rd table?
                        (1) I have a Price Book with product structure. Basically, One Brand(Product) has many Vendors and their price records with effect date.

                        (2) The 3rd table ("Discount") has a vendor, his discount rate with effect date. Our vendor has the discount rate their List price books by each Product.

                        (3) My PriceBook table has a List Cost and Net Cost fields. The Net cost is Calculate field with "List Cost - (list cost * discount rate)" so My intention is whenever I add or edit the PriceBook table date field value, Read the Discount table and get the Discount Rate.