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

Fetch to new record on change event

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

  • Fetch to new record on change event

    All,

    The question is, "Why would a Change end function fetch me to the begining of my records?" This program worked in a A5V8.

    I have a program in a form it updates child records for the parent you are viewing.
    I get the pointer to the parent by using :
    ord = table.current()
    I link to the child by using:
    lots = ord.get("Lot_linker")

    Lot.fetch_First()
    While Lot.fetch_EOF() = .f.
    If "Stuff needs Changed" then
    lot.change_Begin(.t.)
    "Change stuff"
    lot.Change_end(.t.) "Here the pointer will jump to the first child record."
    End if
    lot.fetch_Next()
    End While

    I am running build 2814.

  • #2
    Re: Fetch to new record on change event

    Jesse, did you retype the script(s) ? As presented they won't run at all anywhere. I'm thinking you've made some typos? Any chance you can upload a zipped copy of the database for us to study?


    This may be a case where you need to use Table Cursors. See the help file topic "Table Cursors" or search for
    <tbl>.get_cursor()
    From the helps:

    The primary motivation for this method is to allow you to use Xbasic to get a pointer to the table that an Embedded Browse is based on, and then to safely loop over the records in that table and manipulate the data in that table. If your Xbasic loop used the table pointer itself, rather than a cursor, your script may not work reliably. This is because you have no control over events that cause the Browse to repaint, and when the Browse repaints, it might move the record pointer.
    Last edited by Tom Cone Jr; 05-21-2010, 03:20 PM.

    Comment


    • #3
      Re: Fetch to new record on change event

      I have modified the script to do what I need.
      The short hand I wrote before was because It is in the middle of a long script.
      The script Fetches through a list of lots for a shipment and compares the quantity of all the lots to the amount ordered. Then It deducts each lot from inventroy After that it marks each lot as them as counted and deducted from inventroy.
      Here is the actual script:
      'Date Created: 03-Jun-2009 02:56:50 PM
      'Last Updated: 20-May-2010 02:00:35 PM
      'Created By : Jesse
      'Updated By : jsanders
      'debug(1)
      Dim pack as p
      Dim Found as N
      dim ord as p
      dim ord2 as p
      dim lots as p
      Dim items as p
      dim prod as p
      dim mode as n
      Dim count as n=0
      ord = table.current()
      ord2 = ord.get("orders")
      lots = ord.get("lot_link")
      items = ord.get("Items")
      prod = ord.get("products")
      if lots.mode_get()>0 then
      if lots.mode_get()= 1 then
      lots.change_end(.t.)
      else
      lots.enter_end(.t.)
      end if
      end if
      if Items.mode_get()>0 then
      if Items.mode_get()= 1 then
      Items.change_end(.t.)
      else
      Items.enter_end(.t.)
      end if
      end if
      items.fetch_first()
      if items.fetch_eof() then
      end
      end if
      dim checksum[50] as n
      dim Track[50] as l
      dim units[50]as n
      dim product[50] as n
      dim PrtRpt[50] as c
      Dim CksmFail as L = .f.
      dim rptlist as n
      dim repeat as l
      items.fetch_first()
      prod.fetch_first()
      Count = 1
      track[count] = prod.track_Lots
      rptlist = 1
      PrtRpt[rptlist] = prod.Coa_Rpt
      pack = table.open("packaging",FILE_RW_SHARED)
      pack.index_primary_put("PPN")
      while items.fetch_eof()=.f.
      units[count] = items.units
      lots.fetch_first()
      if lots.fetch_eof().and. Track[count] then
      End
      end if
      while lots.fetch_eof()=.f.
      Checksum[count] = Checksum[count] + lots.Units
      If lots.Posted=.f. then
      Found = Pack.fetch_find(Lots.PACK_LK)
      if Found>0 then
      pack.change_begin(.t.)
      pack.Used=pack.Used+Lots.units
      pack.change_end(.t.)
      end if
      end if
      lots.fetch_next()
      end while
      lots.fetch_first()
      while lots.fetch_eof()=.f.
      if lots.posted=.f. then
      lots.change_begin(.t.)
      lots.Posted = .t.
      lots.change_end(.t.)
      end if
      lots.fetch_next
      end while
      Count = count + 1
      items.fetch_next()
      prod.fetch_first()
      Track[count] = prod.track_lots
      if PrtRpt[rptlist]<> prod.Coa_Rpt then
      repeat = .f.
      if rptlist>1 then
      for i = 1 to rptlist
      if PrtRpt[i] = prod.Coa_Rpt then
      repeat = .t.
      end if
      next
      if repeat = .f. then
      rptlist =rptlist+1
      PrtRpt[rptlist] = prod.Coa_Rpt
      end if
      else
      rptlist =rptlist+1
      PrtRpt[rptlist] = prod.Coa_Rpt
      end if

      end if
      end while
      items.fetch_first()
      for i = 1 to count
      if (Checksum[i] <> Units[i]).and. Track[i] then
      CksmFail = .t.
      ui_msg_box("Warning","Units ordered do not match units Picked",UI_ATTENTION_SYMBOL+UI_OK)
      end if
      Next
      if CksmFail then
      items.fetch_first()
      while items.fetch_eof()=.f.
      lots.fetch_first()
      while lots.fetch_eof()=.f.
      If lots.Posted=.t. then
      Found = Pack.fetch_find(Lots.PACK_LK)
      if Found>0 then
      pack.change_begin(.t.)
      pack.Used=pack.Used-Lots.units
      pack.change_end(.t.)
      end if
      lots.change_begin(.t.)
      lots.Posted = .f.
      lots.change_end(.t.)
      end if
      lots.fetch_next()
      end while
      items.fetch_next()
      end while
      end
      end if
      record_number = current_record_number()
      query.filter = "orders->Ord_indx = " + Str(Orders2:Tables:orders.ORD_INDX,5,0)
      'query.filter = "recno() = " + record_number
      query.order = ""
      ord2.change_begin(.t.)
      ord2.shipped =.t.
      ord2.change_end(.t.)
      if *any(upper(Orders2:Tables:customers.CUST_SHP_TO),"KEEBLER") then
      :Report.Preview("FC_COA_Keebler",query.filter,query.order)
      else
      if rptlist>1 then
      for i = 1 to rptlist
      if PrtRpt[i]>"" then
      :Report.Preview(PrtRpt[i],query.filter,query.order)
      end if
      next
      ELSE
      if PrtRpt[1] >"" then
      :Report.Preview(Orders2:Tables:products.COA_RPT,query.filter,query.order)
      end if
      end if
      end if

      Comment


      • #4
        Re: Fetch to new record on change event

        I couldn't find a help topic or anything about <tbl>.get_cursor() except an explanation in What's New In Version 9.

        Linked here.
        There can be only one.

        Comment


        • #5
          Re: Fetch to new record on change event

          Stan, right. I should have been more explicit. I found it searching the Alphapedia site, which I'm trying to use more and more. I used the google search option there. Thanks for building a better road map.

          Comment


          • #6
            Re: Fetch to new record on change event

            thanks Tom and Stan - this explains an issue I was having!! and a fix!!
            Cole Custom Programming - Terrell, Texas
            972 524 8714
            [email protected]

            ____________________
            "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

            Comment

            Working...
            X