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

Passing calculated variables to fields

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

    Passing calculated variables to fields

    Hello-
    Is there anyway in a script I can pass a calculated variable value on a layout to a field I have in a table? I know I can set the calculated variable as a global, but wanted to know if the calculated variable value on my layout can be passed to the field on a table? I can't remember if I have seen a thread posted on this before.

    Thank you-

    Neecy

    #2
    Re: Passing calculated variables to fields

    Yes and easily.

    When do you want to do this? You have to choose an event and code the event. Is the form single table based or set based?

    Easiest event to use is the form cansave event. Code like

    Code:
    dim tbl as p
    tbl = table.current([COLOR="Red"]1[/COLOR])
    tbl.[COLOR="red"]fieldname[/COLOR] = var->[COLOR="red"]variablename[/COLOR]
    Change the portions in red as appropriate.
    Last edited by Stan Mathews; April 30, 2010, 10:37 AM.
    There can be only one.

    Comment


      #3
      Re: Passing calculated variables to fields

      Single based table. I have a saved button that will save all values to a master table as well as additional custom code I applied. I have a grand total variable calculated on my layout which I will like to pass to a field on my master table.

      Thank you-

      Neecy

      Comment


        #4
        Re: Passing calculated variables to fields

        Suggested script should work for you when you fill in the field and variable names.
        There can be only one.

        Comment


          #5
          Re: Passing calculated variables to fields

          Hi Stan-
          Will this script work on a set based format? I have another layout that's is based on a set.

          Thanks-

          Neecy

          Comment


            #6
            Re: Passing calculated variables to fields

            table.current(1)

            TABLE.CURRENT( [ Slot_Number as N ] )

            Argument
            Description

            Slot_Number
            Optional. Refers to other open tables in the current session. A slot number ranges from 1 to the number of open tables in a session. If your current table is part of a set, Slot 1 is the primary table, Slot 2 is the first child, Slot 3 is the grandchild or the primary table’s second child, and so on. All open tables, whether or not they are part of a set, will occupy slots in the session.
            Just change the slot number to the number of the table to which you wish to write the value. If the table to which you wish to write is the parent of the set of the other form, nothing changes.
            There can be only one.

            Comment


              #7
              Re: Passing calculated variables to fields

              Hi Stan-
              My layout is a set that is displayed by dates. When I apply the code listed below, it will only pass the last variable to the last record. Can this be setup to set the value based on the dates in my bill table? I have included my screen shot of my layout. My layout shows the child tables displayed and grouped by week ending date. The second screen shot shows my grand total bottom right, which is the value I need to post to my bill table which has three fields (date, site_name, total).


              topparent.command("RECORD_COMMIT")

              dim path as c = iif(a5.Get_Master_Path() = "",a5.Get_Path(),a5.Get_Master_Path())
              dim access as c = path


              dim tbl as p
              tbl=table.current(1)
              tbl.fetch_first()

              while .not. tbl.fetch_eof()
              flg=.F.
              tbl.enter_begin(.t.)
              tbl.Invoice=calc->Invoice
              flg=.T.
              tbl.enter_end(flg)
              flg=.F.
              tbl.fetch_next()
              end while
              tbl.close()


              Thanks

              Neecy-

              Comment


                #8
                Re: Passing calculated variables to fields

                Sorry, I don't have a clue what you are saying.

                Your script doesn't post anything. It creates new records.

                Time for a sample?
                There can be only one.

                Comment


                  #9
                  Re: Passing calculated variables to fields

                  No problem. I'll send you a sample.

                  Comment


                    #10
                    Re: Passing calculated variables to fields

                    Hi Stan-

                    The attached sample will give you a better idea of what I am trying to achieve by obtaining the calculated variable values and apply to the 'bill' table.

                    Thanks-

                    Neecy

                    Comment


                      #11
                      Re: Passing calculated variables to fields

                      Hi Stan-

                      Again, I want to thank you. The 'Billing' script disappeared on my end before I sent you the sample database. Attached in word is the script in case you don't see it.

                      Neecy

                      Comment


                        #12
                        Re: Passing calculated variables to fields

                        Ok, we're closer.

                        You want to pass/post the calc->invoice value to the bill.dbf? You want to create a new record in the bill.dbf with the location, date, and calc->invoice value? There are currently 6 records in that table to which we could post.


                        I'm still not clear when you want do this. While viewing a record on the Billing form? You want to do this for all records in the set?

                        Be gentle with me. I'm not usually this slow.
                        There can be only one.

                        Comment


                          #13
                          Re: Passing calculated variables to fields

                          Originally posted by Stan Mathews View Post
                          Be gentle with me. I'm not usually this slow.
                          It must be Friday...
                          Al Buchholz
                          Bookwood Systems, LTD
                          Weekly QReportBuilder Webinars Thursday 1 pm CST

                          Occam's Razor - KISS
                          Normalize till it hurts - De-normalize till it works.
                          Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                          When we triage a problem it is much easier to read sample systems than to read a mind.
                          "Make it as simple as possible, but not simpler."
                          Albert Einstein

                          http://www.iadn.com/images/media/iadn_member.png

                          Comment


                            #14
                            Re: Passing calculated variables to fields

                            Hi Stan-
                            You're doing great :). Actually, the bill.dbf file has 2 fields that are generated from the billing script. I guess what I need to do is update that table with the calc->invoice variable value to the Invoice field. The date field is the date_link field I created to link all the weekly tables together. That way, they will display by the week ending date on the form. (I know, kinda confusing until you review the table set). The only table in the set that I will need the invoice value to post to is the bill.dbf. I intend to extract the bill.dbf table data into another database for reporting purposes only, but will need the value of invoice.

                            Thanks-
                            Neecy

                            Originally posted by Stan Mathews View Post
                            Ok, we're closer.

                            You want to pass/post the calc->invoice value to the bill.dbf? You want to create a new record in the bill.dbf with the location, date, and calc->invoice value? There are currently 6 records in that table to which we could post.


                            I'm still not clear when you want do this. While viewing a record on the Billing form? You want to do this for all records in the set?

                            Be gentle with me. I'm not usually this slow.

                            Comment


                              #15
                              Re: Passing calculated variables to fields

                              This code on a button will post the value of calc->invoice from the form to the current parent record in bill.dbf.

                              Code:
                              parentform.commit()
                              tbl = table.current(1)
                              tbl.change_begin()
                              tbl.invoice = invoice.value
                              tbl.change_end(.t.)
                              parentform.resynch()
                              The same code could also be used on the onfetch event of the form to automatically post the value.
                              Last edited by Stan Mathews; April 30, 2010, 04:25 PM.
                              There can be only one.

                              Comment

                              Working...
                              X