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

Displaying a .value

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

    Displaying a .value

    I have a Save button on a form which, before it actually saves a new record, calculates the value of two fields from data entered on the form.

    I do the arithmetic to find valueA (a numeric) then say:

    objectA.value = valueA

    The value does not appear on the form, although it's saved OK. When I next access that record, or even if I simply re-save it, the values appear. I've tried a parentform.resynch() but it doesn't seem to help. Can you?

    Martin.

    #2
    RE: Displaying a .value

    Martin,

    A5 is doing what it's supposed to do. Use a calculate field instead of putting it on the button.

    kenn
    TYVM :) kenn

    Knowing what you can achieve will not become reality until you imagine and explore.

    Comment


      #3
      RE: Displaying a .value

      Martin,
      To avoid a 75 post thread, it would be helpful to see your script.

      Comment


        #4
        RE: Displaying a .value

        Thanks, Ken and Steve,

        I think the calculation is a bit too complicated to put in field rules, it involves checking a date range in another table, then finding another record in a "rooms" table and from information in both of them, calculating a room charge, which can be over two "seasons". This all works perfectly accurately from the in-line xBasic and a function I've written, but the results don't appear immediately on the form. I could attach the code to On Departing one of the relevant objects on the form, but, at that stage there's no guarantee that the other relevant fields will have been completed, so I though better to put it on the Save button, after the form has been checked for missing data. As I say, everything works fine except for the subsequent display.

        For what it's worth, though, here's the code attached to the OnPush of my Save button (don't know how word-wrap will affect this):

        '' xBasic

        if modifying = .f. .and. adding = .f.
        END
        end if

        '' Rescheck*() are my reservation validation Global Functions which check for missing data:

        m_valid = rescheck1("save", ab.value, rs.value, arrivaldate.value, departdate.value, roomstart.value, roomend.value)
        if m_valid="Fail"
        END
        end if
        m_valid = rescheck2("save", roomname.value, roomtype.value)
        if m_valid="Fail"
        END
        end if
        m_valid = rescheck3("save", status.value, gCode0.value, adults.value, children.value)
        if m_valid="Fail"
        END
        end if
        ''
        topparent.find_Exit()

        ''
        m_arriving = arrivaldate.value
        if (c2date(last_visit.value) 0 .and. roomnights.value > 0
        stdCostDay.value = m_roomCharge / roomnights.value
        else
        stdCostDay.value = 0
        end if

        ''ui_msg_box(str(stdCostTot.value),str(stdCostDay.value))

        end if

        mode = parentform.mode_get()

        if mode = "ENTER" .or. mode = "CHANGE" then

        parentform.commit()
        end if
        if parentform.mode_get()"VIEW" then
        ui_msg_box("Unable to save your changes","Please correct and save, or discard your changes",UI_STOP_SYMBOL)
        end if



        res_input.restrict_enter = .t.
        res_input.restrict_change = .t.
        modifying = .f.
        adding = .f.

        resBrowse.enable()
        entry_mode.text="View"


        END

        Comment


          #5
          RE: Displaying a .value

          Martin,

          No don't put in a calculated field in the field rules, that won't solve your problem. Create a calulated field using the Drag/Drop list and put it in there.

          That should work instantaniously.

          kenn
          TYVM :) kenn

          Knowing what you can achieve will not become reality until you imagine and explore.

          Comment


            #6
            RE: Displaying a .value

            So, I just create a table field, drag it to my form, and, er, attach my code, where?

            Martin.

            Comment


              #7
              RE: Displaying a .value

              Martin,

              First, go to your function and copy the code. Then open the Drag/drop list and drag the to yoour form. Give it a name and the click the small xy icon on the right of the Expression box. Paste the code from the function, click OK and give it a whirl.

              Another way is, when the expression box opens, you might be presented with a list of functions. If so, simply dbl click on the function.

              Click OK and give it a whirl.

              kenn
              TYVM :) kenn

              Knowing what you can achieve will not become reality until you imagine and explore.

              Comment


                #8
                RE: Displaying a .value

                stdCostTot.value = m_roomCharge


                if m_roomCharge > 0 .and. roomnights.value > 0
                stdCostDay.value = m_roomCharge / roomnights.value
                else
                stdCostDay.value = 0
                end

                --------------------------
                I'm assuming these are the form fields you want to refresh.
                I believe if you use the text property here instead of the value property, your form objects (fields) will show the change. If not then follow with stdcosttot.refresh(), stdcostday.refresh().

                Comment


                  #9
                  RE: Displaying a .value

                  That looked very promising, Steve, but,

                  I tried it, and it made no difference; the values don't display after saving a new record (although they will if I come back and modify the record, and THEN save).

                  I can't believe that it's impossible to press a button which instigates a bit of calculation, and for the result to be displayed in an object on the parent form, without all this palava. Surely this sort of thing is needed all the time?

                  Yours, baffled...

                  Martin.

                  Comment


                    #10
                    RE: Displaying a .value

                    I do it on a hundred forms all the time with absolutely no problem. Are you sure that you are referencing the correct object name?--re-check properties. Are you sure that your code is returning a value? --write it the trace window?

                    Comment


                      #11
                      RE: Displaying a .value

                      I think it must be because everything works when modifying an existing record (it's the same code). But I'll check everything again.

                      Thanks,

                      Martin.

                      Comment


                        #12
                        RE: Displaying a .value

                        Steve and everyone,

                        Here's a little example. Before anyone says it: I KNOW this could havebeen done with a calculated field, but the actual problem I'm having involves finding records in other tables, etc, etc, which wouldn't be possible as a calculated field.

                        Anyway, whatever I'm doing wrong (and I'm sure it's something very simple) is reproduced here.

                        All I want to do is press a button and have the result of some processing displayed in a field. In this case, add together two input fields and display the result in a third field.

                        What could be simpler? You tell me.

                        Many, many, thanks for your time and help,

                        Martin.

                        Comment


                          #13
                          RE: Displaying a .value

                          Martin,

                          I examined your example and after some initial confusion discovered a problem with your form. Your code works.

                          You can establish this by editing the form and enabling the code field. Save the form. At this point attempt to edit the field manually and you will see that when you attempt to save the record you get a "no such field" error.

                          Edit the form.
                          Copy the "save" button. Open the default form and enter design mode. Paste in the button and you will see it works as you wish (although the field is not wide enough to hold the content your code attempts to enter--but this is a detail).

                          Let me add that in order to avoid problems later the reference to a field object on the form contained in a button script should be "parentform:code.value" rather than "code.value" as you have it.

                          Bill
                          Bill Hanigsberg

                          Comment


                            #14
                            RE: Displaying a .value

                            Thanks Bill,

                            This is so frustrating (for you as well as for me); I tried your suggestions and still the code doesn't display.

                            Of course, the original form was built on the default form, so, could I have some settings wrong in A5? I've once again attached the changed form, after copying my xBasic, and attaching it, with button, to the default form. I've put a couple of ui_msg_box's in to see what's in memory at certain times. It looks as if nothing is being stored to parentform:code.value even 'though nom and numero are obviously correct.

                            Any more suggestions gratefully received. Looks as if I may have a sleepless weekend.....

                            Martin.




                            =============================
                            '' This code is attached to the "Save" button:
                            numero = parentform:number.value
                            nom = parentform:name.value
                            ui_msg_box(nom,str(numero))
                            parentform:code.value = upper(substr(nom,1,3))+str(numero)
                            ui_msg_box("TEST",parentform:code.value)
                            parent.commit()

                            Comment


                              #15
                              RE: Displaying a .value

                              Martin:

                              Here's an example of a really newbie's response to this challenge. An 'On_depart' event from the Room Number field. It uses a form variable to display the findings of the script and is refreshed on the spot. The 'Save' button just commits the record. All of your code is attached to that depart event. I'm sure my solution here is laughable to more experienced users but it's all I have.

                              Ken

                              Comment

                              Working...
                              X