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

How to automatically save the record?

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

    #16
    Re: How to automatically save the record?

    P.S. After you execute the update query, then your function should probably refresh your grid so the checkbox shows that it is checked.
    functionName = "{grid.Object}.refresh();"
    Carol King
    Developer of Custom Homebuilders' Solutions (CHS)
    http://www.CHSBuilderSoftware.com

    Comment


      #17
      Re: How to automatically save the record?

      Well I must be stupid. This does not work either. No error message. Just doesn't work.

      function AfterInsertRecord as v (e as p)
      'debug(1)

      'connect to the SQL database
      dim cn as sql::Connection
      dim flag as l
      flag = cn.open("::name::conn")
      if flag = .f. then
      AfterInsertRecord = "alert('Could not connect to database');"
      exit function
      end if

      'SQL Query (fields that will be written to)
      dim sqlUpdate as C
      sqlUpdate = <<%sql%
      update journal
      (posted)
      values
      (:posted)
      %sql%

      'map fields for the first record
      dim args as sql::Arguments
      args.add("posted",.t.)

      'execute the sql using arguments first transaction
      flag = cn.execute(sqlUpdate,args)
      if flag = .f. then
      dim errorTxt as C
      errorTxt = js_escape(cn.CallResult.text)
      cn.close()
      AfterInsertRecord = "alert('Could not update SQL statement. Error reported was: "+errorTxt+" ');"
      exit function
      end if

      dim rowsUpdated as N
      rowsUpdated = cn.CallResult.rowsAffected
      cn.close()

      end function

      Comment


        #18
        Re: How to automatically save the record?

        NOT STUPID! This stuff is tough!!! (at least I think so...)

        First, you said your grid is read only, so I don't think using the AfterInsertRecord would work. I don't think you can insert a record on a read only grid. Perhaps you need to use the OnChange event of the field you have just changed on the client side. (Or if it is a check box, maybe the OnClick event?)

        Second, I think your query statement might need to be something more like below (but I don't know what type of back end database you have so I may not be right), and it seems like you would need a where clause to identify the record you are updating based on a primary key field (using an argument that gets the primary key field value). You would put your primary key field name where the question marks are:
        Code:
        update journal set posted = :posted where ?????? = :???????
        For the where, seems like you would have to use a primary key field from your grid to match the primary key in the table you are updating, .
        Carol King
        Developer of Custom Homebuilders' Solutions (CHS)
        http://www.CHSBuilderSoftware.com

        Comment


          #19
          Re: How to automatically save the record?

          Betty, for some reason I can't get a clear picture of what you are trying to do. I think it would help whoever might want to help you here if you do a video demonstrating your grid and identifying its structure.
          Carol King
          Developer of Custom Homebuilders' Solutions (CHS)
          http://www.CHSBuilderSoftware.com

          Comment


            #20
            Re: How to automatically save the record?

            Aaahhh .. I have satellite here .. it doesn't play well with video and if I download or upload too much they throttle me and then I have no internet. To try to make it simpler .. I have two tables; a journal and a ledger. I am using a mySQL database with alphadao. This is what I want to do (and I can do all of it except save the record at step #3; whether I use a grid or detail view):

            1. Enter a record in the journal
            2. When I save that record, write two splits to the ledger.
            3. Mark the journal record as posted and save that change to that record.

            I know that the sql statement that I want to use is 'update journal posted = true" (ie. done). For what seems like such a simple thing .. yes .. it seems a bit convoluted. I probably make it worse than it needs to be because I have tried two dozen things and have gotten the same result no matter what I do; I can create the journal entry, I can create the ledger entries, I can update the posted value to true .. but I cannot save that updated record. I think that what I am trying to do is a common thing that everybody does; but I cannot find an answer to it.

            I have looked at your work and you do a wonderful job; I cannot imagine that it has been so tough for you.

            Maybe I will try to do a video after 2am when Hughes lets up on the fair access threshold.

            Comment


              #21
              Re: How to automatically save the record?

              Hey Betty,

              Give this a try. I've tried to duplicate your situation. I have a read only grid, but I haven't attached any linked grids or detail grids - that shouldn't matter. The Post button (my button) updates a MySQL table and then refreshes the current row. As you say, your journal entry and ledger entries are going in ok so maybe this is just the last piece. Here is the code. It really isn't any different than yours. This is an Ajax Callback running a function. Let me know if this is close... don't worry... we'll get it. I don't know what you're using in your MySQL table for the Posted field. I'm using a type of TinyInt(1).

              Code:
              function PostJournal as c (e as p)
              'This function will handle the Ajax callback. 
              'It must return a string of Javscript commands that will be executed in the Browser.	
              
              dim cn as sql::Connection 
              dim args as sql::Arguments
              dim sqlSelect as c
              dim flag as l
              
              flag = cn.open("::Name::YOURCONNECTIONSTRING","YOURSQLLOGIN","YOURPASSWORD")
              
              sqlSelect = "UPDATE tblorders SET Posted ='1' WHERE OrderId='" + e._currentRow + "'"
              flag = cn.Execute(sqlSelect)
              'You can check the flag here to make sure it updated ok
              
              'And now, refresh just the row you are on
              PostJournal = "{grid.Object}.refreshRow("+e._currentRow+");"
              
              cn.Close()
              
              end function
              Attached Files
              Last edited by Davidk; December 08, 2011, 08:40 PM.

              Comment


                #22
                Re: How to automatically save the record?

                I'm glad you did that, David. I kept wishing I could find time to write some sample code for Betty, and was going to include the refresh, but my plate is way too full at year end. I'm pulling for her!
                Carol King
                Developer of Custom Homebuilders' Solutions (CHS)
                http://www.CHSBuilderSoftware.com

                Comment


                  #23
                  Re: How to automatically save the record?

                  Well that worked .. thank you

                  Comment

                  Working...
                  X