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

Goto Record Number?

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

    Goto Record Number?

    I created the script below using Action Scripting and I can't see why it won't work. I want to navigate to a specified record when switching from one form to another. I set the global variable, vn_rec_no, to the correct record number and use it to specify the record. Yet, when the new form opens, it always goes to the first record in the table.

    The funny thing is that I can execute the Goto Record Number command as a script once the form is open and it works fine. I would appreciate any ideas on what I need to do to make this work.

    'Open a Form or Browse layout, displaying all, or selected records in the layout.

    DIM Shared varP_admin_frm as P
    DIM layout_name as c
    layout_name = "Admin_frm"
    DIM tempP as p

    'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it

    tempP=obj(":"+object_Name_normalize(word(layout_name,1,"@")))

    'Test if pointer is valid

    if is_object(tempP) then
    'Test if pointer refers to a form or browse
    if tempP.class() = "form" .or. tempP.class() = "browse" then
    'If so, then activate the already open window
    tempP.activate()

    else
    'Window is not already open, so open it
    varP_admin_frm = :Form.view(layout_name)


    end if
    else
    varP_admin_frm = :Form.view(layout_name)


    end if

    'Set the index to : 'Log_Num' in current window.

    topparent.Index_SetExplicit("")

    'Go to a specified record number in current form at parent level.

    DIM var_recno_target as N
    var_recno_target = vn_rec_no
    topparent.recno_goto(var_recno_target)

    'Close the form/browse called: cut_log_frm

    DIM window_to_close as C
    window_to_close = "cut_log_2"
    DIM varP_Window as p

    'If the window name was specified without a leading ":", then add it.

    if left(alltrim(window_to_close),1) <> ":" then
    window_to_close = ":"+alltrim(window_to_close)
    end if

    'Get a pointer to the specified window

    varP_Window = obj(window_to_close)

    'Check if the specified window really exists

    if .not. is_object(varP_Window) then
    ui_msg_box("Error","Can not close the window 'cut_log_2' because it is not open.",UI_STOP_SYMBOL)
    end
    else
    'Check to see that the object supports the "close()" method
    if .not. varP_Window.has_method("close") then
    ui_msg_box("Error","Can not close 'cut_log_2' because it is not a window.",UI_STOP_SYMBOL)
    else
    'The window does exist, so close it
    'Check to see that the object supports the "mode_get()" method
    if varP_Window.has_method("mode_get") then
    'Save any unsaved data before closing the window
    DIM mode as c
    mode = varP_Window.mode_get()
    if (mode = "ENTER" .or. mode = "CHANGE") then
    varP_Window.commit()
    'Check to see if the record was successfully saved
    if varP_Window.mode_get()<>"VIEW" then
    ui_msg_box("Unable to save your changes","Please correct and save, or discard your changes", UI_STOP_SYMBOL)
    end
    end if
    end if
    end if
    'Close the window
    varP_window.close(.f.)
    end if
    end if

    #2
    Re: Goto Record Number?

    I don't know where you are getting the record number from, but will guess its from the current form. In my example, I'll assume an imaginary set for the current form, and have you double click on the browse showing multiple child records. You want to open a form for the child table for that record.

    2 possibilities - 1) you want the 2nd form fixed ONLY on the single child record and 2) you want it to open to that record, but permit navigation to other records.

    dim global rnum as n
    t=table.current(2)
    rnum=t.recno()

    '1
    form.viewqueried("childformname","recno()=var->rnum")

    '2
    f=form.load("childformname")
    f:index_set("")
    f.find(rnum)
    f.show()
    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


      #3
      Re: Goto Record Number?

      Martin, thanks for the bit of code. In fact, I am switching between forms for the parent record.

      I am as interested in knowing why the script generated through Action Scripting doesn't work as I am in a fix for the problem. I use Action Scripting, as I don't write Xbasic and that works about 90% of the time. The rest of the time I run into things that I don't understand, but can usually figure out. In this case, I'm stumped as to why it won't work. It seems as if it should work.

      Comment


        #4
        Re: Goto Record Number?

        it looks like it is querying the current form to the current record number, rather than the one you opened - why not use a/s to 'zoom' to the form - then look at that code to see the differences.
        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


          #5
          Re: Goto Record Number?

          Martin, thank you for your insight and your time. I have tried the zoom feature, but it requires movement from an embedded browse to a form based on the same table as the embedded browse. I am navigating between to forms at the parent level, so that did not work for me.

          I understand your idea that A5 may be basing the query on the form that was closed, not the open form, but I don't understand the mechanics of this. I have re-ordered the sequence of commands so that one form closes before the other opens. The goto command does not execute to until the new form is open. I've checked and the variables are available in the new form and have correct values.

          The code for the goto command is:

          DIM GLOBAL var_recno_target as N
          var_recno_target = vn_rec_no
          topparent.recno_goto(var_recno_target)

          With no other forms open, why shouldn't "topparent.recno_goto(var_recno_target)" not execute correctly? If I open the form and then run this as a script manually, it works fine. I must be missing something in terms of how A5 functions here.

          Comment


            #6
            Re: Goto Record Number?

            Jeff, this would be easier to investigate with a working copy to explore.

            First thought here is that the object reference "topparent" may be referencing the calling form, instead of the called form.

            Shouldn't you be using varP_admin_frm to reference the called form?

            It may be as simple as telling the action script which form you are trying to manipulate.

            Comment


              #7
              Re: Goto Record Number?

              Originally posted by Tom Cone Jr View Post

              Shouldn't you be using varP_admin_frm to reference the called form?

              It may be as simple as telling the action script which form you are trying to manipulate.
              Tom, I mostly work with what Action Scripting hands me. So I'm puzzled when a function doesn't work as it appears it should. I'll see if I can post an example.

              Comment


                #8
                Re: Goto Record Number?

                Martin,Tom, thank you helping me to think this through. I overlooked the Action Scripting feature that lets one explicitly state which form for which one is setting the index. The resulting code does the trick.

                'Open a Form or Browse layout, displaying all, or selected records in the layout.

                DIM Shared varP_cut_log_2 as P
                DIM layout_name as c
                layout_name = "cut_log_2"
                DIM tempP as p
                'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
                tempP=obj(":"+object_Name_normalize(word(layout_name,1,"@")))
                'Test if pointer is valid
                if is_object(tempP) then
                'Test if pointer refers to a form or browse
                if tempP.class() = "form" .or. tempP.class() = "browse" then
                'If so, then activate the already open window
                tempP.activate()

                else
                'Window is not already open, so open it
                varP_cut_log_2 = :Form.view(layout_name)


                end if
                else
                varP_cut_log_2 = :Form.view(layout_name)


                end if

                'Set the index to : '<Record Number Order>' in current window.
                DIM object_name as C
                object_name = ":"+"cut_log_2"
                DIM varP_Object as p
                'Get a pointer to the specified object
                varP_Object = obj(object_name)
                'Check if the specified object exists
                if .not. is_object(varP_Object) then
                ui_msg_box("Error","The object '"+object_name+"' does not exist.",ui_stop_symbol)
                else
                varP_Object.Index_SetExplicit("")
                end if

                'Go to a specified record number in current form at parent level.
                DIM var_recno_target as N
                var_recno_target = vn_rec_no
                DIM object_name as C
                object_name = ":"+"cut_log_2"
                DIM varP_Object as p
                'Get a pointer to the specified object
                varP_Object = obj(object_name)
                'Check if the specified object exists
                if .not. is_object(varP_Object) then
                ui_msg_box("Error","The object '"+object_name+"' does not exist.",ui_stop_symbol)
                else
                varP_Object.recno_goto(var_recno_target)

                end if

                Comment

                Working...
                X