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

OnFetch not working when using Find By Key or Queries

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

    OnFetch not working when using Find By Key or Queries

    I have several routines which are run in the OnFetch() event on a form. One routine looks to see if a photo exists for the record and if so updates the bitmap field on the form. Another checks to see what class of real estate is being displayed (Residential, Farm, Commercial) and hides or makes visible different fields and labels on the form that apply only to that specific type of property. Everything works perfectly EXCEPT when I move to a new record using a query, filter or Find by Key in which case the first record that shows does not update all of the fields and the photo as the form does not fire the OnFetch() event. I've added the same code to the OnActivate() event and when I click off of the form and back onto it after doing a query, filter or find the fields update properly. This would seem to be a bug in Alpha V11 that's been around awhile as the OnFetch() event I would think should fire every time the form moves to a new record regardless of the method used to navigate.

    Any assistance would be most appreciated.
    Brad Weaver, President
    ComputerAid International
    Ottawa ON Canada
    Versailles KY USA
    www.compuaid.com

    #2
    Re: OnFetch not working when using Find By Key or Queries

    when I click off of the form and back onto it after doing a query, filter or find the fields update properly
    May be time for a parentform.resynch() or parentform.repaint() after the code for the onfetch?
    There can be only one.

    Comment


      #3
      Re: OnFetch not working when using Find By Key or Queries

      Has this ever worked, for example in earlier versions of alpha Five?

      I'm not sure this is a a bug. The onFetch event in the form is probably a very different thing than the fetch_next method in the underlying table. Shouldn't be too hard to test. I'll get back to you on this, and will watch for other posts, too.

      Comment


        #4
        Re: OnFetch not working when using Find By Key or Queries

        If I put the code

        ui_msg_box("","Fetch.")

        on the onfetch event for a form the message appears whether I page up/down, find by key, or query by expression.
        There can be only one.

        Comment


          #5
          Re: OnFetch not working when using Find By Key or Queries

          Brad,

          Maybe this screencast will help explain what's going on.

          http://screencast.com/t/iLsjqbnXiGR

          Comment


            #6
            Re: OnFetch not working when using Find By Key or Queries

            The OnFetch is not firing at all when I use queries or Find By Key. I've submitted this as a bug report along with a sample database that demonstrates the issue. I even added a msgbox which simply says "It fired" which shows up fine when moving from record to record but does not popup when I search using Find By Key or a query.
            Brad Weaver, President
            ComputerAid International
            Ottawa ON Canada
            Versailles KY USA
            www.compuaid.com

            Comment


              #7
              Re: OnFetch not working when using Find By Key or Queries

              Bummer -red faced-
              I'm testing in V10.5.
              Disregard if you're only using V11.



              Can you attach your sample here? It did fire for me (using AlphaSports) if I understand the situation.
              There can be only one.

              Comment


                #8
                Re: OnFetch not working when using Find By Key or Queries

                Tom,

                Thanks so much for your explanation and taking the time to generate a screencast. I see how moving the pointer in the underlying table would not trigger the OnFetch event but what I'm wanting to do is to run either the Query Genie or click on the GUI Find By Key either of which I seem to force a form refresh (as the data on the form changes) but neither of which fires the OnFetch event. Again, this only happens when the form is based on an Active Link table. With a DBF table the OnFetch event on the form DOES fire when you use either of these methods. Also, if I use Find By Key and Record Number the OnFetch event fires even for an Active Link table.

                Here's a screencast that will demonstrate what I'm talking about:

                http://www.screencast.com/t/G8zdNdhzaej
                Brad Weaver, President
                ComputerAid International
                Ottawa ON Canada
                Versailles KY USA
                www.compuaid.com

                Comment


                  #9
                  Re: OnFetch not working when using Find By Key or Queries

                  Ok. I missed the point that you were using a form based on an active link table.

                  Comment


                    #10
                    Re: OnFetch not working when using Find By Key or Queries

                    Originally posted by Tom Cone Jr View Post
                    Ok. I missed the point that you were using a form based on an active link table.
                    Here's the response from Selwyn. The issue I'm left with is how do I run code once the underlying table or query changes. Perhaps a new event is needed (OnRequery):

                    Thanks

                    Here is what's happening and why we don't think it is a bug.

                    Find by key for an active link table is different than find by key for a native table.
                    For a native table, FBK positions the record pointer without changing the number of records in the current query.
                    For an active link, since there is no concept of a local index, FBK is translated into a query, and the number of records in the current query is changed - it becomes one.

                    In your case you were on physical record number 1 when you opened the form.
                    You did a FBK and the active link table gets dynamically repopulated with just 1 record - the record you were trying to find.
                    You are STILL on record 1 - so as far as a5 is concerned, the record number has not changed and so onFetch does not fire.

                    If you have moved to record 2 before you did the FBK, then you would see the onFetch does fire.

                    We can debate whether this is a bug or not, but it is irrelevant - we are not going to make any changes to this functionality.
                    Brad Weaver, President
                    ComputerAid International
                    Ottawa ON Canada
                    Versailles KY USA
                    www.compuaid.com

                    Comment


                      #11
                      Re: OnFetch not working when using Find By Key or Queries

                      Selwyn made a good suggestion that spurred me on to a solution to this issue. With the advent of dynamic properties for most items now I solved my photo issue by creating a function that retrieves the name of the first photo that matches my key field and also populates a file array with the names of other photos for the same record if they exist. The same function sets the visibility of the photo selector button and updates the Image X of Y fields on the form. By passing a logical parameter to the function I can set whether or not the function is being called from a Form or a report and thus reuse the same function to display the image of the house on my property report as well.

                      The only thing I discovered was that dynamic fields trigger continuously while a form is displayed and since my function was looking at the hard drive directory structure every time it was called to populate the file name I was using a lot of CPU cycles. I added a flag at the beginning of the function that checks to see if the currently displayed record has changed and if not I exit the function without performing any additional processing. This reduced my CPU usage back to basically idle.

                      In case someone is interested in the techniques used, here's how I did it -

                      The function I created is called GetPhotoName and takes two logical parameters: IsForm and Force. IsForm is true for forms and False for reports. Force, if true, tells the function to run regardless of whether the current data on the form has changed. I place this in the Dynamic property of the Filename on a Bitmap control as:

                      GetPhotoName(.t.,.f.)

                      The function source code is:

                      'Date Created: 08-Nov-2011 10:28:04 PM
                      'Last Updated: 09-Nov-2011 07:36:23 AM
                      'Created By : Administrator
                      'Updated By : Administrator
                      FUNCTION GetPhotoName AS C (isform as L,force as L)
                      'This function takes the current map number from the calling form
                      'and locates all photos from the directory specified in the Settings
                      'table and stores them to an array "FileArray", setting the bitmap.
                      'The function returns the fully qualified name of the first photo that
                      'matches. This function should be called from the dynamic function.
                      'The parameter isform should be .T. if the calling object is on a form
                      'otherwise it should be set to .F. for reports.
                      'The Force parameter is used to force the routine to execute regardless
                      'of whether the currentmap is the same.


                      Dim shared currentmap as C
                      if isform then

                      ' Since dynamic properties get called constantly, exit the function if
                      ' the map number hasn't changed to avoid eating up cpu cycles
                      if currentmap = parentform:map_no.value .and. .not. force then
                      return
                      end if
                      end if


                      DIM files AS c
                      DIM shared filearray[1000] as p

                      filearray.clear()
                      if isform then
                      ' Record the currently displayed map number so we can avoid continuously running the rest of this function while the record pointer remains the same.
                      currentmap = topparent:Map_no.value
                      else
                      ' Get the map number from the Map_No textbox on the current record
                      currentmap = topparent:Map_no.value
                      end if
                      if len(trim(currentmap))=0 then
                      'Do not display or even attempt to locate photos if there is no map number
                      'this.object.visible = .f.
                      if isform then
                      imgnum = 0
                      totimgs = 0
                      topparent:control_Bitmap1.object.visible = .f.
                      parentform:txtImgCnt.text = ""
                      parentform:btnNextPicture.object.visible = .f.
                      else
                      topparent:control_Bitmap1.object.visible = .f.
                      end if
                      return
                      end if
                      path = Settings.PhotoDirectory()
                      files = filefind.get(path+chr(92)+alltrim(currentmap)+"*.jpg",4096,"PN")
                      filearray.initialize_properties("name",files)

                      if isform then
                      parentform:btnNextPicture.object.visible = .f.
                      end if

                      if filearray.first_empty()>1 then
                      GetPhotoName=filearray[1].name
                      if isform then
                      topparent:control_Bitmap1.object.visible = .t.
                      imgnum = 1
                      totimgs = filearray.first_empty()-1
                      parentform:txtImgCnt.text = "Image "+alltrim(str(imgnum))+" of "+alltrim(str(totimgs))
                      if totimgs>1 then
                      parentform:btnNextPicture.object.visible = .t.
                      end if
                      else 'Report
                      ' Show only the first matching picture on reports
                      topparent:control_Bitmap1.object.visible = .t.
                      end if
                      else
                      if isform then
                      imgnum = 0
                      totimgs = 0
                      topparent:control_Bitmap1.object.visible = .f.
                      parentform:txtImgCnt.text = ""
                      parentform:btnNextPicture.object.visible = .f.
                      else
                      topparent:Control_bitmap1.Object.Visible = .f.
                      end if
                      GetPhotoName=""
                      end if
                      END FUNCTION
                      Brad Weaver, President
                      ComputerAid International
                      Ottawa ON Canada
                      Versailles KY USA
                      www.compuaid.com

                      Comment


                        #12
                        Re: OnFetch not working when using Find By Key or Queries

                        Thanks!

                        Comment


                          #13
                          Re: OnFetch not working when using Find By Key or Queries

                          One last note of interest. If you look at the code above there's a line that reads

                          path = Settings.PhotoDirectory()

                          I decided to give version 11's updated ability to create and use classes a spin. I created a table called Settings that contains all of the main application info that might change when the program is deployed (think web.config in the .Net world) and then setup up a class called MySettings which I instantiate to Settings as a global class in the autoexec routine. This makes all of the methods of Settings available to me throughout the application so I have object oriented access to my Settings table data. At present I have only created read (Get) functions but it would be just as easy to create write (Set) functions. This really adds to Alpha's flexibility as a fully object oriented environment. Nice job Alpha! I'm feeling better everyday about the decision to switch my company's flagship product over to Alpha...
                          Brad Weaver, President
                          ComputerAid International
                          Ottawa ON Canada
                          Versailles KY USA
                          www.compuaid.com

                          Comment

                          Working...
                          X