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

Alternative method to enter/edit Memo field

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

    Alternative method to enter/edit Memo field

    Due to having history of corrupt memo fields in our tables, I am attempting to utilize an alternative method of entering and editing memo fields. My idea is to reduce the time the record is in enter or edit mode as much as possible. Our users use these notes fields extensively and may spend 10 minutes at a time entering and editing notes. My thought is to make the memo field on the form read only and then have the user enter/edit the notes via an xdialog box and then transferred to the memo field when the user presses ok, thus putting the record in edit mode only when the user presses ok, instead of all the while they are entering the notes.

    I've attached a sample that allows the user to enter the notes via an xdialog but am not sure how to go about creating a button to edit the contents of the memo field by copying the current contents into an xdialog box, making the necessary changes, then replacing what was in the memo field with the contents of the edited text in the xdialog.

    Sample_Notes.zip

    Appreciate any suggestions.

    Also, I welcome any criticism or advice with my logic.

    Thanks!

    #2
    Re: Alternative method to enter/edit Memo field

    I'm contemplating reworking some of our note fields as well as we just had some pretty scary corruption occur.

    For you Edit button would something as simple as this work? Just reuse your xdlg code but get the note contents just before.


    Code:
    [B]DIM tbl as P
    DIM SHARED NotesVar as C
    tbl = table.current()
    NotesVar = tbl.NOTES[/B]
    
    
    
    DIM SHARED DialBox as C
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    DialBox = ui_dlg_box("Enter Internal Notes",<<%dlg%
    {region}
    Notes:| [%mw%.60,8NotesVar];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    
    If Dialbox = "Cancel"
    	var->NotesVar=""
    	end
    End If
    
    If Var->NotesVar=""
    	end 
    	ELSE
    
    Dim P as P
    DIM SHARED Test AS C
    
    vMode = parentform.mode_get()
    
    IF vMode = "CHANGE" .or. vMode = "ENTER"
    	parentform.commit()
    END IF
    
    tbl = table.current() 
    p.text=tbl.Notes
    
    tbl.change_begin()
    [B]
    'Save the note
    tbl.Notes = var->NotesVar[/B]
    
    
    tbl.change_end(.t.)
    Notes.refresh()
    topparent.commit()
    
    'maybe add a catch here to make sure the commit went through
    
    NotesVar = ""
    END IF
    You could probably also add the code to commit the changes within the xdlg itself. If you add Error handling to verify the commit went through it might be a good idea. You could present an option to retry. It might also give the user a chance to copy their work to word/notepad if they fear it won't save properly.
    Last edited by mgallardo; 03-19-2019, 11:14 AM. Reason: Bolding changes / wraping in code tag

    Comment


      #3
      Re: Alternative method to enter/edit Memo field

      I've had excellent results using this code with memo fields.
      This script is attached to a button on the form and the memo field is read only.

      The nice thing about this script, the memo field is only open long enough to save the change or the enter.
      This script handles both entering a new memo or editing an existing memo.

      In this example, this memo is in a grandchild table.

      Ron

      Code:
      parentform.Commit()
      tparent = table.current(1)
      tgchild = table.current(2)
      vtransno = tgchild.TRANSNO
      vSwkno = tgchild.SWKNO
      
      dim shared t as p
      t = table.get("WOfix")
      p.text=t.action
      
      IF t.action = "" .and. t.swkno = "" THEN
      	IF a5_memo_editor(p,"Edit the Corrective Action Field") = "Save" THEN
      		vSwkRec = tgchild.recno()
      		t = table.open("WOfix")
      		t.enter_begin()
      		t.TRANSNO = vtransno
      		t.SWKNO = vswkno
      		t.action = p.text
      		t.enter_end()
      		t.close()
      		END
      	ELSE
      		cancel()
      		end
      	END IF
      ELSE
      	IF a5_memo_editor(p,"Edit the Corrective Action Field") = "Save" THEN
      		vRec = t.recno()
      		t = table.open("WOfix")
      		t.fetch_goto(vRec)
      		t.change_begin()
      		t.action = p.text
      		t.change_end()
      		t.close()
      	ELSE
      		cancel()
      		end
      	END IF
      END IF
      
      parentform.Resynch()
      
      END
      Alpha 5 Version 11
      AA Build 2999, Build 4269, Current Build
      DBF's and MySql
      Desktop, Web on the Desktop and WEB

      Ron Anusiewicz

      Comment


        #4
        Re: Alternative method to enter/edit Memo field

        I can't swear my thinking is correct, but I think the fpt errors are usually caused by disk activity.
        For myself, I've abandoned the dbf memo field in favor of large varchar sql columns as they seem
        to be far more reliable, and you can easily connect them to the record involved.
        Gregg
        https://paiza.io is a great site to test and share sql code

        Comment


          #5
          Re: Alternative method to enter/edit Memo field

          Originally posted by mgallardo View Post
          I'm contemplating reworking some of our note fields as well as we just had some pretty scary corruption occur.

          For you Edit button would something as simple as this work? Just reuse your xdlg code but get the note contents just before.


          Code:
          [B]DIM tbl as P
          DIM SHARED NotesVar as C
          tbl = table.current()
          NotesVar = tbl.NOTES[/B]
          
          
          
          DIM SHARED DialBox as C
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          DialBox = ui_dlg_box("Enter Internal Notes",<<%dlg%
          {region}
          Notes:| [%mw%.60,8NotesVar];
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%)
          
          If Dialbox = "Cancel"
          	var->NotesVar=""
          	end
          End If
          
          If Var->NotesVar=""
          	end 
          	ELSE
          
          Dim P as P
          DIM SHARED Test AS C
          
          vMode = parentform.mode_get()
          
          IF vMode = "CHANGE" .or. vMode = "ENTER"
          	parentform.commit()
          END IF
          
          tbl = table.current() 
          p.text=tbl.Notes
          
          tbl.change_begin()
          [B]
          'Save the note
          tbl.Notes = var->NotesVar[/B]
          
          
          tbl.change_end(.t.)
          Notes.refresh()
          topparent.commit()
          
          'maybe add a catch here to make sure the commit went through
          
          NotesVar = ""
          END IF
          You could probably also add the code to commit the changes within the xdlg itself. If you add Error handling to verify the commit went through it might be a good idea. You could present an option to retry. It might also give the user a chance to copy their work to word/notepad if they fear it won't save properly.
          Marco,

          This appears to work fine. Is there a way to not have the current contents of the memo field selected and place the cursor at the end of the existing text when the dialog box is opened?

          Thanks for the help!

          Comment


            #6
            Re: Alternative method to enter/edit Memo field

            Originally posted by Mark Williams View Post
            Is there a way to not have the current contents of the memo field selected and place the cursor at the end of the existing text when the dialog box is opened?
            Don't think I've done that one before but I'll give it a go:
            Code:
            DIM tbl as P
            DIM NotesVar as C
            DIM ptrNotesVar as P
            DIM ptrNotesVar.Object as P
            DIM ptrNotesVar.text as C
            tbl = table.current()
            'NotesVar = tbl.NOTES
            ptrNotesVar.text = tbl.NOTES
            
            
            DIM SHARED DialBox as C
            ok_button_label = "&OK"
            cancel_button_label = "&Cancel"
            
            dlgTitle = "Enter Internal Notes"
            DialBox = ui_dlg_box(dlgTitle,<<%dlg%
            {startup=loadingXdlg}
            {region}
            Notes:| [%mw%.60,8ptrNotesVar];
            {endregion};
            {line=1,0};
            {region}
            <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
            {endregion};
            %dlg%,<<%code%
            if a_dlg_button = "loadingXdlg" then
            	a_dlg_button = ""
            	ui_dlg_ctl_goto(dlgTitle,"ptrNotesVar")
            	ptrNotesVar.Object.set_cursor(len(ptrNotesVar.text)+1)
            end if
            %code%)
            
            If Dialbox = "Cancel"
            	ptrNotesVar.text = ""
            	end
            End If
            
            If ptrNotesVar.text = ""
            	end 
            ELSE
            	Dim P as P
            	DIM SHARED Test AS C
            	
            	vMode = parentform.mode_get()
            	
            	IF vMode = "CHANGE" .or. vMode = "ENTER"
            		parentform.commit()
            	END IF
            	
            	tbl = table.current() 
            	p.text= tbl.Notes
            	
            	tbl.change_begin()
            	
            	'Save the note
            	tbl.Notes = ptrNotesVar.text
            		
            	tbl.change_end(.t.)
            	Notes.refresh()
            	topparent.commit()
            	
            	'maybe add a catch here to make sure the commit went through
            	
            	ptrNotesVar.text = ""
            END IF
            I used an xdialog startup event to set the cursor and had to change the xdialog field to a pointer as per the documentation

            https://documentation.alphasoftware...._.SET_CURSOR()

            Comment


              #7
              Re: Alternative method to enter/edit Memo field

              Originally posted by mgallardo View Post
              Don't think I've done that one before but I'll give it a go:
              Code:
              DIM tbl as P
              DIM NotesVar as C
              DIM ptrNotesVar as P
              DIM ptrNotesVar.Object as P
              DIM ptrNotesVar.text as C
              tbl = table.current()
              'NotesVar = tbl.NOTES
              ptrNotesVar.text = tbl.NOTES
              
              
              DIM SHARED DialBox as C
              ok_button_label = "&OK"
              cancel_button_label = "&Cancel"
              
              dlgTitle = "Enter Internal Notes"
              DialBox = ui_dlg_box(dlgTitle,<<%dlg%
              {startup=loadingXdlg}
              {region}
              Notes:| [%mw%.60,8ptrNotesVar];
              {endregion};
              {line=1,0};
              {region}
              <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
              {endregion};
              %dlg%,<<%code%
              if a_dlg_button = "loadingXdlg" then
              	a_dlg_button = ""
              	ui_dlg_ctl_goto(dlgTitle,"ptrNotesVar")
              	ptrNotesVar.Object.set_cursor(len(ptrNotesVar.text)+1)
              end if
              %code%)
              
              If Dialbox = "Cancel"
              	ptrNotesVar.text = ""
              	end
              End If
              
              If ptrNotesVar.text = ""
              	end 
              ELSE
              	Dim P as P
              	DIM SHARED Test AS C
              	
              	vMode = parentform.mode_get()
              	
              	IF vMode = "CHANGE" .or. vMode = "ENTER"
              		parentform.commit()
              	END IF
              	
              	tbl = table.current() 
              	p.text= tbl.Notes
              	
              	tbl.change_begin()
              	
              	'Save the note
              	tbl.Notes = ptrNotesVar.text
              		
              	tbl.change_end(.t.)
              	Notes.refresh()
              	topparent.commit()
              	
              	'maybe add a catch here to make sure the commit went through
              	
              	ptrNotesVar.text = ""
              END IF
              I used an xdialog startup event to set the cursor and had to change the xdialog field to a pointer as per the documentation

              https://documentation.alphasoftware...._.SET_CURSOR()
              Nicely done, Marco!

              One last question (I hope)...

              If there is existing text in the memo field and I delete it all, it should delete all the existing text. Instead, it ends the script. Any suggestions on a fix for that?

              Thanks again!

              Comment


                #8
                Re: Alternative method to enter/edit Memo field

                Sure.


                Just remove or comment out this If Block from you code

                Code:
                [COLOR="#FF0000"]If ptrNotesVar.text = ""
                	end 
                ELSE[/COLOR]
                
                <Keep the code between the Else and End if>
                
                [COLOR="#FF0000"]END IF[/COLOR]

                Comment


                  #9
                  Re: Alternative method to enter/edit Memo field

                  Originally posted by mgallardo View Post
                  Sure.


                  Just remove or comment out this If Block from you code

                  Code:
                  [COLOR="#FF0000"]If ptrNotesVar.text = ""
                  	end 
                  ELSE[/COLOR]
                  
                  <Keep the code between the Else and End if>
                  
                  [COLOR="#FF0000"]END IF[/COLOR]
                  Works perfectly - thanks again - it's really appreciated!

                  Comment


                    #10
                    Re: Alternative method to enter/edit Memo field

                    Gregg,
                    Are you saying you switched to sql from dbf, or that you are pairing a sql table to handle the notes with your existing dbf table. If the latter, please give more details.

                    Bill.

                    Comment


                      #11
                      Re: Alternative method to enter/edit Memo field

                      My intent was to switch, but the desktop form has so many conditional controls that I
                      paired them up.

                      I use the recno() from dbf to match the exact record, as empID to match up with the employee (this gives me more options).
                      I also take advantage of using grid and dialog components to display/receive data entry.
                      Gregg
                      https://paiza.io is a great site to test and share sql code

                      Comment


                        #12
                        Re: Alternative method to enter/edit Memo field

                        So using a desktop form with an embedded web component to show the memo? Is this done via OnFetch event to retrieve the memo for each dbf record displayed? Or are you putting an active link table in a set with a dbf table?

                        Comment


                          #13
                          Re: Alternative method to enter/edit Memo field

                          I actually have them click a button, but of the options you provided, I would use the onFetch event as my
                          experience with active link tables was that they were horribly slow.
                          Gregg
                          https://paiza.io is a great site to test and share sql code

                          Comment


                            #14
                            Re: Alternative method to enter/edit Memo field

                            Hi Ron,
                            I use something similar but have not tried to trap the save button in the memo editor. The only thing I would do different since the WOfix table is already open via the form, is use table.open_session() to do the enter. I am going to try your script and see how it works.
                            Robin

                            Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                            Comment


                              #15
                              Re: Alternative method to enter/edit Memo field

                              Originally posted by mgallardo View Post
                              Don't think I've done that one before but I'll give it a go:
                              Code:
                              DIM tbl as P
                              DIM NotesVar as C
                              DIM ptrNotesVar as P
                              DIM ptrNotesVar.Object as P
                              DIM ptrNotesVar.text as C
                              tbl = table.current()
                              'NotesVar = tbl.NOTES
                              ptrNotesVar.text = tbl.NOTES
                              
                              
                              DIM SHARED DialBox as C
                              ok_button_label = "&OK"
                              cancel_button_label = "&Cancel"
                              
                              dlgTitle = "Enter Internal Notes"
                              DialBox = ui_dlg_box(dlgTitle,<<%dlg%
                              {startup=loadingXdlg}
                              {region}
                              Notes:| [%mw%.60,8ptrNotesVar];
                              {endregion};
                              {line=1,0};
                              {region}
                              <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                              {endregion};
                              %dlg%,<<%code%
                              if a_dlg_button = "loadingXdlg" then
                              	a_dlg_button = ""
                              	ui_dlg_ctl_goto(dlgTitle,"ptrNotesVar")
                              	ptrNotesVar.Object.set_cursor(len(ptrNotesVar.text)+1)
                              end if
                              %code%)
                              
                              If Dialbox = "Cancel"
                              	ptrNotesVar.text = ""
                              	end
                              End If
                              
                              If ptrNotesVar.text = ""
                              	end 
                              ELSE
                              	Dim P as P
                              	DIM SHARED Test AS C
                              	
                              	vMode = parentform.mode_get()
                              	
                              	IF vMode = "CHANGE" .or. vMode = "ENTER"
                              		parentform.commit()
                              	END IF
                              	
                              	tbl = table.current() 
                              	p.text= tbl.Notes
                              	
                              	tbl.change_begin()
                              	
                              	'Save the note
                              	tbl.Notes = ptrNotesVar.text
                              		
                              	tbl.change_end(.t.)
                              	Notes.refresh()
                              	topparent.commit()
                              	
                              	'maybe add a catch here to make sure the commit went through
                              	
                              	ptrNotesVar.text = ""
                              END IF
                              I used an xdialog startup event to set the cursor and had to change the xdialog field to a pointer as per the documentation

                              https://documentation.alphasoftware...._.SET_CURSOR()
                              Is it possible to change the font size in the dialog box? I believe it's defaulting to an 8 pt font and I'd like to change it to 10 pt.

                              Thanks

                              Comment

                              Working...
                              X