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

changing field on current form

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

    changing field on current form

    what is the best way to address the currently viewed record in a form, no matter which index is selected, so a field value can be changed with a button click? i have it working withe the following, but i'm wondering what the preferred method is.

    tbl = table.open("table.dbf")
    record_number = current_record_number()
    tbl.FETCH_GOTO(record_number)

    #2
    Re: changing field on current form

    I'm not clear on the issue. What happens after the code given? What type of change takes place?

    The easiest way to address a field in the current record in the table upon which a form is based is to refer to the field's value on the form. That form object needn't be visible.
    There can be only one.

    Comment


      #3
      Re: changing field on current form

      sorry, just thought you could tell me how to make sure i was editing the current record.


      tbl = table.open("pfs1.dbf")
      record_number = current_record_number()
      tbl.FETCH_GOTO(record_number)
      tbl.change_begin()
      fld1 = tbl.field_get("acct")
      acctnum1 = fld1.value_get()
      fld2 =tbl.field_get("acct2")
      fld2.value_put(acctnum1)
      tbl.change_end(.T.)

      Comment


        #4
        Re: changing field on current form

        Gary, why would you think the record on screen is not the current record? Are you trying to update a field that's visible on screen? Are you trying to update a field that's hidden? Is the field in the primary table, is it in a child table in a set supporting your form?

        Comment


          #5
          Re: changing field on current form

          tom:

          when i ran this code without:
          record_number = current_record_number()
          tbl.FETCH_GOTO(record_number)

          i was returning a value from another record, not the one that was visible on the form. so i added those 2 lines and it seemed to work. i think it was always returning a value from the first record until i added those 2 lines.

          Comment


            #6
            Re: changing field on current form

            hmmm... sadly, color me confused...

            Comment


              #7
              Re: changing field on current form

              sorry, so am i. you can see what i want to do in this example, copy the value from one filed to the next in the currently viewd record on a form.

              how would you do it?

              Comment


                #8
                Re: changing field on current form

                First, I'd familiarize myself with the object names in the form. These are often the same as the table fieldnames, but not necessarily.

                Then, I'd review the help file discussion of Objects and Object Addresses. You can address an Object in code using it's actual name (Absolute Addressing) or by Reference to its relative position in the form (Relative addressing). This is fundamental for anyone writing code to manipulate field values in forms with scripts.

                Then, I'd check the properties of the field objects in question to discover that they have both TEXT and VALUE properties. The object explorer is the tool to use to learn how to do this.

                Depending upon the data type of the information being moved from one field to another I'd either

                :actualformname:actualfield1name.text = :actualformname:actualfield2name.text

                or

                :actualformname:actualfield1name.value = :actualformname:actualfield2name.value

                Notice the colons and the periods. As explained in the reference materials colons are used sort of like slashes in a DOS path statement, to permit you to describe a specific object in a layout. These snippets would tell Alpha Five to find a particular form, then look for a particular object, then assign either TEXT or a VALUE to a property of that particular object.

                Notice also that these snippets assume that object to be manipulated is found in the form, and does not "live" in a different object. This may not be obvious, but if you were trying to manipulate the column value in the currently selected row of a browse named "browse1", your syntax would have to be changed:

                :Parentform:Browse1:Columname.text

                See the difference?

                Understanding how to reference objects in your layouts is fundamental, and well worth the time it takes to work through the related help file materials.

                Comment


                  #9
                  Re: changing field on current form

                  thanks for the explanation, but maybe i'm expecting too much here. in the excel progamming forums where i hang out, i and a lot of others actually write the code to the op can see what's happening. a lot of us write some elaborate code, recreate forms and spreadsheets to help the op see what's going on. if i was responding to this question in the excel forums, i actually would have created the form and written the few lines of code to show the user how to accomplish this.

                  but, i guess that's a different animal. that's why i don't know or remember everything about alpha, 95% of my apps are done in excel. it's hard to remeber the syntax going between both apps.

                  just my opinion here.

                  Comment


                    #10
                    Re: changing field on current form

                    oh, and i wasn't taking issue with what you posted, it does help to a point, i was merely pointing out the differences between the 2 forums.

                    sorry if it came out the wrong way

                    Comment


                      #11
                      Re: changing field on current form

                      No offense taken.

                      Here the practice is more often for the initial poster to attach a sample that illustrates the problem, so that volunteers can furnish specific advise. You asked a general question. You got a general answer. Sorry it didn't meet your expectations.

                      Comment


                        #12
                        Re: changing field on current form

                        ok, good. is there anything wrong with the way i'm doing it?

                        Comment


                          #13
                          Re: changing field on current form

                          Gary,

                          Changing/setting values using table methods as you are doing is fine but more work and unnecessary when you have the means on the form right on the screen. After doing so you may very well have to do a :actual_form_name.resynch() as well as the view of the data the form has, does not "know" that the table values it is based on has changed.

                          Tom was attempting to teach you how to fish instead of simply giving you a fish. Without the very basics of how to use Alpha means that you would always be struggling--none of us like to see that with anyone for any length of time.

                          Regarding how other forums respond--I have done some researching on many various forums (excel, access, quickbooks, filemaker,....) just to see how members/posts/etc. are treated and none have come close to this forum. ...Maybe I just hit the other forums at the wrong time but I see the responders here go WAY beyond what would normally be expected of anyone giving their time for free!!

                          Just another opinion... :)
                          Mike
                          __________________________________________
                          It is only when we forget all our learning that we begin to know.
                          It's not what you look at that matters, it's what you see.
                          Henry David Thoreau
                          __________________________________________



                          Comment


                            #14
                            Re: changing field on current form

                            i think you would get a response in the excel forum. i know i have about 200 posts since sept. i don't always come up with what the op is looking for, but i do write some code, and a lot of others write some elaborate code, all for free, too.

                            if i saw my post in excel, i would have responded with the following. it took me 5 minutes and struggling in alpha takes me an hour. that's why i help in excel, so people see actual code examples.

                            Private Sub CommandButton1_Click()
                            Dim newacct As String
                            Dim acct1 As String
                            Dim acct2 As String
                            newacct = Application.InputBox("enter new acct number", , , , , , , 1)
                            With UserForm1
                            .TextBox2.Value = .TextBox1.Value
                            .TextBox1.Value = newacct
                            End With
                            End Sub

                            Comment


                              #15
                              Re: changing field on current form

                              Gary, did my code suggestions not work for you?

                              While your approach will work I prefer to minimize traffic on the network. Your code opens another instance of the table, finds the correct record, updates the field value, and then closes the table. You should resynch your form if you use this code, since the form will not display the new value automatically.

                              If the field is available on the form (one of several questions I asked of you which were never answered) it's much better to use the current instance of the table, than to open another.

                              Even if the desired field is not available in the form layout you can update the field's value using a pointer to the current instance of the table, rather than open a completely new instance. I'll spare you the details since I've apparently overstayed my welcome in the first place. Bye.

                              -- tom

                              Comment

                              Working...
                              X