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

Any tips for creating buttons to Enter,Change, Save, Cancel records?

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

    Any tips for creating buttons to Enter,Change, Save, Cancel records?

    OK I am trying to create buttons on my form for users to work with the records in a table. I have Enter, Change, Save, Cancel, and Main Menu buttons. The key is I want to enable/disable buttons depending on the state of the record. So for example if the user presses the "Change" button, all the remaining buttons are disable except "save" and "cancel".

    The code I have create *(SO FAR)* to the function is at the bottom of this post. This is comming along OK, but there just seems like there could an easier way.

    I got to looking at the wizard and how it creates buttons and I ran across this code:
    Code:
    topparent.command("RECORD_COMMIT")
    I was unable to find any documentation on this "command" method. I was interested in using it if it would make my life easier :).


    *Any* tips regarding creating a buttons for this type thing is appreciated. Also any information on the command method is appreciated. Thanks :)

    Code:
    FUNCTION TestButton AS V (ButtonPressed_par AS C, form_par AS P )
    	
    Dim CurrentFormMode as C
    
    CurrentFormMode = form_par.mode_get()
    
    select
        case CurrentFormMode = "VIEW"
        	select
        	    case ButtonPressed_par = "btnEnter"
        	    	'put the form in Enter Mode
        	    	
        	    	'disable buttons
        	    	form_par:btnEnter.Disable()
        	    	form_par:btnChange.Disable()
        	    	form_par:btnMainMenu.Disable()
        	    	'Enable save and cancel buttons
        	    	form_par:btnCancel.Enable()
        	    	form_par:btnSave.Enable()
    				end   	    	
        	    case ButtonPressed_par = "btnChange"
        	    	'Put the form in Change Mode
        	    	
        	    	'disable buttons
        	    	form_par:btnEnter.Disable()
        	    	form_par:btnChange.Disable()
        	    	form_par:btnMainMenu.Disable()
        	    	'Enable save and cancel buttons
        	    	form_par:btnCancel.Enable()
        	    	form_par:btnSave.Enable()
    				end  	
        	    case ButtonPressed_par = "btnMainMenu"
        	    	'Close the form
        	    	form_par.close()
        	    Case else
        	    	'the user pressed an invalid button
        	    	'Reset the buttons to what they should be in "VIEW" mode.
        	    	form_par:btnEnter.Enable()
        	    	form_par:btnChange.Enable()
        	    	form_par:btnMainMenu.Enable()
        	    	form_par:btnCancel.Disable()
        	    	form_par:btnSave.Disable()
        	    	end
        	end select
        
        case CurrentFormMode = "ENTER" .OR. CurrentFormMode = "CHANGE"
        	select
        	    case  ButtonPressed_par = "btnSave"
        	    	'We try to save the record, if successful
        	    	on error goto SaveErrorHandler
        	    	IF CurrentFormMode = "ENTER" then
        	    	    
        	    	end if
        	    	IF CurrentFormMode = "CHANGE" then
        	    	    form_par.change_end(.T.)
        	    	end if
        	    	
        	    	
        	    	
        	    	'we go back to view mode and reset the buttons to what they should be in VIEW mode
        	    	form_par:btnEnter.Enable()
        	    	form_par:btnChange.Enable()
        	    	form_par:btnMainMenu.Enable()
        	    	form_par:btnCancel.Disable()
        	    	form_par:btnSave.Disable()
        	    	end
        	    	
        	    	SaveErrorHandler:
        	    	
        	    case  ButtonPressed_par = "btnCancel"
        	    	'We cancel the new/editted record
        	    	form_par.cancel()
        	    	'we go back to view mode and reset the buttons to what they should be in VIEW mode
        	    	form_par:btnEnter.Enable()
        	    	form_par:btnChange.Enable()
        	    	form_par:btnMainMenu.Enable()
        	    	form_par:btnCancel.Disable()
        	    	form_par:btnSave.Disable()
        	    	end
        	    case Else
        	    	'the user pressed an invalid button
        	    	'Reset the buttons to what they should be in "Enter" mode.
        	   
        	end select
        case CurrentFormMode = "QUERY"
        	form_par.query_exit()
        	'kill query mode
        	'then recall the function with the parameters and quit
        	
        case CurrentFormMode = "FIND"
        	form_par.find_exit()
        	'Tell the user they were in query mode and exit
        case else
        	'Serious error, The form is in a state that Alpha says it cant get into.
        	
    end select
    END FUNCTION

    #2
    Mike,

    If you want to see an xbasic example showing one approach to this sort of thing, check out the Basic Data Entry Form examples in the Code Archive Forum. Though written for earlier versions of Alpha Five, they will work just fine with A5v7.

    -- tom

    Comment


      #3
      .Command()

      Mike,

      The best of my undersatnding about the .Command() method is that it uses "A5 Built in Actions"

      You can follow this better if you edit a menu or toolbar. You will see the list of Built in Actions (see attached pic).

      Hope this helps,

      Scott

      Comment


        #4
        one way to disable buttons using OnPush event

        Hi Mike,

        This is what I use in the OnPush event of my Edit Record button:

        'show cancel and save buttons, hide other buttons
        parentform:cancelchanges.show()
        parentform:savechanges.show()
        parentform:newrecord.hide()
        parentform:editrecord.hide()
        parentform:deleterecord.hide()
        parentform:closeform.hide()

        'enable the cancel and save changes buttons
        parentform:cancelchanges.enable()
        parentform:savechanges.enable()

        Don't know if this is easier for you or not. Just another means to the end.

        Cheryl
        Cheryl
        #1 Designs By Pagecrazy
        http://pagecrazy.com/

        Comment


          #5
          Thanks for all the help. I stole something from each post :).

          I looked up .command() method and the help file says its for internal use only. So I am probably going to try and stay away from it. Not knowing the return types and such is to much risk to put that method in app and give to a customer when I dont know what it is really doing.


          Just wanted to say thank you to all. It is appreciated.

          Thanks again,
          Mike

          Comment


            #6
            All the above examples work, but to me are very tedious to enter.
            Being the lazy person I am, and have a form with over 50 buttons to disable, I was looking for a less tedious solution.

            The following code seems to work quite well and is easy to write. The only down side I can see, if you would name your buttons something other than 1,2,3 or you would like to use a note by each button, ie. 1 'save 2 'enter , then I do not believe this will work.

            I just started playing with this and so far it seems to be working quite well.

            Ron

            Disable button onpush code:

            list = <<%a%
            2
            5
            7
            8
            9
            14
            27
            28
            29
            30
            31
            34
            %a%

            FOR each foo in list
            eval("parentform:button" + foo + ".disable()")
            NEXT
            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


              #7
              That is a slick littel trick. The only downside to that trick is you have to know what button32 is as opposed to button 35 for example. But I am going to try to use that trick for some other scenarios.

              Comment


                #8
                How about combining Ron's method with the use of something like the following command in the Interactive Editor to get a list of all the buttons:
                Code:
                ?Menu_main.Child_Enum("f=button")
                = Customers_btn
                Billing_Status_btn
                Expenses_btn
                Vendors_btn
                Reports_btn
                Quit_btn
                Backup_btn
                Indexes_btn
                Contacts_btn
                Phones_btn
                Customers_btn0
                Customers_btn1
                Ctl_pnl_dsn_btn
                Once you have the list, just copy and paste the results into your script. You can easily remove any buttons you don't want to hide/disable. (Obviously, the "=" sign in the first row has to be removed as well.)

                Then change the eval() command to:
                eval("parentform:" + foo + ".disable()")

                For anyone not familiar with constructing a command like this (a) "Menu_main" is the name of my form and (b) the form has to be opened before running the command.

                As you can see, I agree with mbmonk, buttons, or any object type, with names like Button1, Button2, Button3, are pretty hard to work with. That's why I use my Group Format command to rename them. Just select every object on the form (Ctrl-A), open the addin (click the icon in the menu bar), and click the "Rename Buttons" button. The complete process takes a whole couple of seconds. Browses, field objects, and text objects can be renamed just as easily.

                For the really observant among you, the Ctl_pnl_dsn_btn was renamed manually. That button doesn't have any text on it at all so it would have been named simply "Btn".
                Last edited by CALocklin; 03-03-2006, 01:11 PM.

                Comment

                Working...
                X