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

Open Browse and navigate to a record

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

    Open Browse and navigate to a record

    I have a form based on a set. The form has a calculated field that displays the current record number of the header table. I have a button on the form that opens a browse based on the header table only. I want to look at the header information only. When I open the browse, I want the current header record of the form to be the active record in the browse.

    I can open the browse, but everything I tried to make the active browse record the same as the form does not work.

    Code:
    DIM GLOBAL vnCurRec AS n
    vnCurRec = parentform:vnrecno.value
    
    'Open a Browse layout
    :Browse.view("FamIly_List")
    	
    dim t as p
    t = table.current()
    t.fetch_goto(vnCurRec)
    
    END
    I'm sure this is simple. For some reason, I'm just drawing a blank.

    Ron
    Alpha 5 Version 11
    AA Build 2999, Build 4269, Current Build
    DBF's and MySql
    Desktop, Web on the Desktop and WEB

    Ron Anusiewicz

    #2
    Re: Open Browse and navigate to a record

    The following works and not a variable is used to store or pass the record number.

    Code:
    [COLOR="blue"]'dim pointer  variable that will point to the browse.[/COLOR]
    dim br as P 
    [COLOR="blue"]'the browse.view method returns a pointer to the opened browse. ie 'br'[/COLOR]
    br = browse.view("FamIly_List")
    
    [COLOR="red"]'Using this pointer and the table_get() method gets a pointer to the underlying table. 
    'br.[B]table_get()[/B][/COLOR]
    '[COLOR="darkorange"]Then add the fetch_goto() method to go to the wanted record.[/COLOR]
    'br.table_get().[COLOR="darkorange"][B]fetch_goto()[/B][/COLOR]
    
    '[COLOR="green"]The value for the fetch_goto() method is supplied by getting a pointer to the current table using table.current() [/COLOR]
    [COLOR="darkorchid"]'and then the recno() method that belongs to that pointer.[/COLOR]
    
    br.[COLOR="red"]table_get()[/COLOR].[COLOR="darkorange"]fetch_goto([/COLOR][COLOR="green"]table.current()[/COLOR].[COLOR="darkorchid"]recno()[/COLOR][COLOR="darkorange"])[/COLOR]
    
    [COLOR="blue"]'Now resynch the browse to the table underlying the browse[/COLOR]
    br.Resynch()
    Without that comments and colour
    Code:
    dim br as P 
    br = browse.view("FamIly_List")
    br.table_get().fetch_goto(table.current().recno())
    br.Resynch()
    Last edited by Tim Kiebert; 06-09-2011, 01:18 AM.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

    Comment


      #3
      Re: Open Browse and navigate to a record

      Thank you Tim,

      Very simple.
      Thank you for taking the time to explain the code.


      Ron
      Alpha 5 Version 11
      AA Build 2999, Build 4269, Current Build
      DBF's and MySql
      Desktop, Web on the Desktop and WEB

      Ron Anusiewicz

      Comment


        #4
        Re: Open Browse and navigate to a record

        Tim I have wanted to ask how putting these methods together is determined for a long time - can you explain it to me?

        br.table_get().fetch_goto(table.current().recno())
        Robin

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

        Comment


          #5
          Re: Open Browse and navigate to a record

          I will try.

          browse.view("FamIly_List") returns a pointer the browse that is opened. - br

          So br is now a pointer to a browse object. The browse object has methods that includes table_get() which returns a pointer to the underlying table. That table also has methods including fetch_goto() So we could do this:
          Code:
          dim tbl as P
          tbl = br.table_get()
          tbl.fetch_goto()
          tbl is now sort of like a middle man.

          br.table_get() returns a pointer to the table but that pointer does not need to be assigned to a variable. Since we now have a pointer to the table we can use its methods. In this case fetch_goto()

          How do you determine which ones you can string together? Talk it through as above and see if it makes sense and then try it to see if it works. After you do a few you will get better at it.

          I use this construction if I know that I don't need the pointer again later in the code.
          It is also useful in the expression builder.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


            #6
            Re: Open Browse and navigate to a record

            Thanks Tim - seeing how the tbl pointer acts as a mediary makes sense of it for me.
            Robin

            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

            Comment


              #7
              Re: Open Browse and navigate to a record

              When going to a record (on a form):
              Isn't the .fetch_goto() method risky for usage in a multi-user environment? ~because it's relying on recno()

              And much safer to use .find like this:
              Code:
              dim vp_Form as P = parentform.this
              vp_Form.index_set("invoice_number")
              vp_Form.find(vc_InvoiceNo)
              vp_Form.refresh()
              I'm not certain whether I should be using vp_Form.resynch() instead of vp_Form.refresh() here... (refresh should do it since a re-query isn't necessary)
              Last edited by SNusa; 02-13-2012, 12:17 PM.
              Robert T. ~ "I enjoy manipulating data... just not my data."
              It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
              RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

              Comment


                #8
                Re: Open Browse and navigate to a record

                Originally posted by MoGrace View Post
                Tim I have wanted to ask how putting these methods together is determined for a long time - can you explain it to me?

                br.table_get().fetch_goto(table.current().recno())

                dim vp_tbl as P
                dim vp_FieldName as P
                dim vc_tmp as C


                This works:
                vp_tbl.field_get("description").value_put(vc_tmp)

                So does this:
                msgbox("FIELDNAME:",vp_tbl.field_get("description").value_put(vc_tmp))


                According to wiki help, <table>.field_get() method returns a pointer which can be assigned.

                This works too:
                vp_FieldName= vp_tbl.field_get("description")
                vp_FieldName.value_put(vc_tmp)
                msgbox("FIELDNAME:",vp_FieldName.name_get())

                This does not TOTALLY work ~ if vp_FieldName is strictly declared as type P:
                vp_FieldName= vp_tbl.field_get("description").value_put(vc_tmp)
                'Can't get beyond this as debugger indicates pointer value returned is of type N. ~in this case, the value returned from this method is zero (0)

                Is it because the last method (.value_put method) is field method, which does not return any pointer?
                I guess that if you are "foolish enough" to concatenate like this, then the final "method" is what does the "returning?" (if this final "method" returns a value)

                Also, could someone please comment regarding post #7 above?

                ~Thanx
                Robert T. ~ "I enjoy manipulating data... just not my data."
                It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                Comment


                  #9
                  Re: Open Browse and navigate to a record

                  Originally posted by Tim Kiebert View Post
                  I will try.

                  browse.view("FamIly_List") returns a pointer the browse that is opened. - br

                  So br is now a pointer to a browse object. The browse object has methods that includes table_get() which returns a pointer to the underlying table. That table also has methods including fetch_goto() So we could do this:
                  Code:
                  dim tbl as P
                  tbl = br.table_get()
                  tbl.fetch_goto()
                  tbl is now sort of like a middle man.

                  br.table_get() returns a pointer to the table but that pointer does not need to be assigned to a variable. Since we now have a pointer to the table we can use its methods. In this case fetch_goto()

                  How do you determine which ones you can string together? Talk it through as above and see if it makes sense and then try it to see if it works. After you do a few you will get better at it.

                  I use this construction if I know that I don't need the pointer again later in the code.
                  It is also useful in the expression builder.
                  Old thread, but something worth noting regarding "the middle man" approach:
                  Within script, you can concatenate methods and read an object properties..... But you cannot assign object properties this way.

                  For example, the following red colored code (below) fails to work as expected.
                  Code:
                  dim vp_OBJ2 as P
                  vp_OBJ2 = obj(alltrim(LineItem.value))
                  For each LineItem in vc_EnumeratedFormObjectList
                       obj(alltrim(LineItem.value)).hide()  'WORKS FINE.
                       vp_OBJ2.object.visible= (.NOT. obj(alltrim(LineItem.value)).object.visible)  'ALSO WORKS FINE (no middleman)
                  
                       [COLOR="#FF0000"]obj(alltrim(LineItem.value)).object.visible=[/COLOR] (.NOT. obj(alltrim(LineItem.value)).object.visible)  'Left hand side of equation [COLOR="#FF0000"]FAILS[/COLOR]
                       ui_msg_box("",obj(alltrim(LineItem.value)).object.visible)  'WORKS
                  next
                  Last edited by SNusa; 12-23-2013, 04:04 AM.
                  Robert T. ~ "I enjoy manipulating data... just not my data."
                  It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                  RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                  Comment


                    #10
                    Re: Open Browse and navigate to a record

                    "Afterthought" regarding previous post: Possibly wrapping a portion of the failing property code (in red below) within the eval() method might make the property assignment work? Answer, sort of....
                    (But only because the name of the object is extracted before being appended with ".object.visible" prior to invoking eval().)

                    Much of the code below was "trial & error." Of particular interest is the two lines of red code. Also, notes in blue near bottom.

                    Code:
                    'Date Created: 11-Feb-2012 02:54:05 PM
                    'Last Updated: 02-Jan-2014 02:03:48 PM
                    'Created By  : SNUSA
                    'Updated By  : Business
                    dim vp_Form as P = parentform.this
                    lst = vp_form.CHILD_ENUM("f=field")
                    msgbox("",lst)
                    'debug(1)
                    for each thingy in lst
                     	'msgbox("THINGY",thingy.value + "=" + eval(thingy.value+".object.enabled"))  'WORKS
                     	'ii=eval(thingy.value+".object.enabled")  'WORKS
                     	'ui_msg_box("II",ii)  'WORKS
                     	'ui_msg_box("II",eval(thingy.value + ".object.enabled"))  'WORKS
                     	eval(thingy.value + ".object.enabled") = (.not. eval(thingy.value+".object.enabled"))  'WORKS OK...
                     	eval(thingy.value + ".object.visible") = (.not. eval(thingy.value+".object.visible"))  'WORKS OK... (repeated to instantly "undo" process above)
                    
                     	
                    	'eval(thingy.value + ".object.enabled") = (.not. eval(thingy.value+".object.enabled")) 'WORKS OK....
                    	''''eval(thingy +".object.enabled") =  (.not. eval(thingy +".object.enabled")) 'WORKS OK....
                    		'because objects properties can be read, and properties can be set, just not with chaining/concatenation...  See below:
                    	Next
                    	'end
                    	
                    'TESTING CONCATENATING FOR PROPERTY CONTROL....	
                    	dim vc_PlaceHolder as c = "topparent.hide()"
                    	dim vp_OBJ2 as P
                    'vp_OBJ2 = obj(alltrim(LineItem.value))
                    
                    For each LineItem in lst
                    	'obj(alltrim(LineItem.value)).hide()  'WORKS FINE.
                    	'vp_OBJ2.object.visible= (.NOT. obj(alltrim(LineItem.value)).object.visible)  'ALSO WORKS FINE (no middleman)
                    	'eval(LineItem.value + ".object.enabled") = (.not. eval(LineItem.value+".object.enabled"))  'WORKS OK... (no chaining/concatenation)
                    	'eval(LineItem.value + ".object.visible") = (.not. eval(LineItem.value+".object.visible"))  'WORKS OK...  (no chaining/concatenation)
                    
                    	[COLOR="#FF0000"]'eval(obj(alltrim(LineItem.value) + ".object.visible")) = (.NOT. obj(alltrim(LineItem.value)).object.visible) [/COLOR] 'ONLY the Left hand side of equation FAILS  (both sides are identical)
                    	'eval(vp_OBJ2 + ".object.visible") = (.NOT. obj(alltrim(LineItem.value)).object.visible)  'Left hand side of equation FAILS (here we tried to combine pointer w/text)
                    
                    	vp_OBJ2 = obj(alltrim(LineItem.value)) 'this represents enumeated form objects, used in a loop
                    	[COLOR="#FF0000"]vp_OBJ2.object.visible= (.NOT. obj(alltrim(LineItem.value)).object.visible)[/COLOR] 'WORKS with the exact same code on RHS (as the other red code above), not "breaking" here!!!!!
                     	'ui_msg_box("TEST:",obj(alltrim(LineItem.value))+ .object.visible)
                     	'vp_OBJ2.object.visible 'WORKS
                    	'ui_msg_box("A:",vp_OBJ2.object.visible)  'WORKS
                    	'ui_msg_box("A:",obj(alltrim(LineItem.value)).object.visible)  'WORKS
                    	'vp_OBJ2.object.visible = .F. 'WORKS
                    	'vp_OBJ2.object.visible= (.NOT. obj(alltrim(LineItem.value)).object.visible) 'WORKS
                    	
                    	'eval(obj(alltrim(LineItem.value) + ".object.visible")) = (.NOT. obj(alltrim(LineItem.value)).object.visible)  'FAILS Left hand side of equation FAILS
                    	'obj(alltrim(LineItem.value)).object.visible = .F. 'FAILS / DOES NOT WORK (due to LH side of equation not resolving when trying to assign a property instead of "chaining"used to concat/assign property instead of method)
                    	'evaluate_template(eval(obj(alltrim(LineItem.value))) + ".object.visible  = .F.") 'FAILS
                    	'obj(alltrim(LineItem.value)).object.visible = .F. 'DOES NOT WORK (due to LH side of equation not resolving when trying to assign a property instead of "chaining"used to concat/assign property instead of method)
                    
                    	
                    	'eval(LineItem.value + ".object.visible") = (.not. eval(LineItem.value+".object.visible"))  'OK - HMMMM.......  THIS WORKS....
                    
                        ui_msg_box("A:",obj(alltrim(LineItem.value)).object.visible) 'WORKS
                        obj(alltrim(LineItem.value)).hide() 'WORKS
                        eval(obj(alltrim(LineItem.value)).name() +".object.visible") = .F. '  WORKS /RESOLVES FINE because name properly .name() returns text value before appending "object.visible" prior to using eval()!!!!
                        ui_msg_box("A:",vp_OBJ2.object.visible) 'WORKS
                        
                    [COLOR="#0000CD"][B]'NOTES:
                        'When setting a object's property (unlike when applying a method or "reading" property attibutes) you cannot use concatenation.
                        'Instead, you must first eval the Left hand side of the equation using the objects name attribute.
                        'What I had been trying to do incorrectly (logic) was concatenate a pointer and text together.
                        'Apparently, (unlike object methods) when working with object properties, Alpha has the ability to "resolve" the construct & "read" the property value. 
                        'values on the right hand side of the equation.
                        'Concatenation (Linking) ONLY works when an objects function/method returns a pointer value.
                        'AND Providing a method returns a pointer value, you can concatenate/string object methods together on the LH (and RH) side of the equation.
                        'With properties, you can only "READ" them (to resolve object properites) ~  Providing the object's method (return pointer) exists.
                        'No matter what you do, an concatenated (chaining of methods/functions/properties) ends when an object's property is involved.
                        'Now the question is:  Can you also do this with functions when a pointer value is returned....??????  HMMMM
                        'ANSWER IS YES! (A command like vp_Form = Form.view("MySecondForm".).hide() will open and hide the form.
                        'And, this code (on the primary form) will close the form:  vp_Form.close()... (after the "form_init" event on other form fires)[/B][/COLOR]
                        
                        'evaluate_template(vc_PlaceHolder)
                    	'end
                    
                        'ui_msg_box("B:",obj(alltrim(LineItem.value)).object.visible) OK 
                         'ui_msg_box("TEST:",eval(obj(alltrim(LineItem.value) + ".object.visible")))     'JUNK
                         'ui_msg_box("",obj(alltrim(LineItem.value)).object.visible)  'WORKS
                    next
                    Last edited by SNusa; 01-02-2014, 04:21 PM.
                    Robert T. ~ "I enjoy manipulating data... just not my data."
                    It's all about the "framework." (I suppose an "a5-induced" hard drive crash is now in order?)
                    RELOADED: My current posting activity here merely represents a "Momentary Lapse Of Reason."

                    Comment

                    Working...
                    X