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

OnKey Events

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

  • OnKey Events

    What's wrong with this code? I get "dim a_user.key.value as c: variable frame bad". Apparently the "+" character is not being trapped, but writes it in the field. I copied the code from the Alpha help file, which says nothing about dimming the pointer variable, by the way.

    dim a_user as p
    dim a_user.key as c
    dim a_user.key.value as c
    if a_user.key.value = "+"
    sys_send_keys("{ctrl}{enter}")
    end if

    Here's what I'm trying to do. Maybe you have a better way to accomplish this. I don't want the clerk to touch the keyboard.

    There's a subform to enter invoice line items in. We use a scanner to populate the "barcode" field whose OnWrote field rule event looks up the item in the catalog and populates the rest of the fields. Using the keyboard, ctrl-enter works accomplishes this task just fine. But I need to do this with the scanner.

    I have a barcode of the "+" character taped to the counter. The clerk scans an item barcode, then scans the "+" barcode, which is supposed to save the record and move to the next line for more barcode entry. Thus the sys_send_keys() in the code above. Although it works in A4, I can't get it to work in A5.

    Any assistance would be invaluable.

  • #2
    Re: OnKey Events

    So is the problem getting the input from the scanner, or how the script is handling the specific field value? If you press the plus key does the script run? If so that suggests the problem is getting input from the scanner. Maybe what you need is to set focus to a text box in the form and let the onchange event of that box handle the input from the scanner... I'm not sure the onKey event will ever fire if the only input is supplied through the serial port...

    Comment


    • #3
      Re: OnKey Events

      The scanner inputs the data into the field perfectly, Tom. What I want to do is ctrl-enter at that point so I can do it again with another item, and so on. I figure that, if I used an onkey script to do this and placed it in the field rules as an onarrive event, the "+" would fire if keyed, not append it to the data. But the code I'm using throws an error. Perhaps someone could show me a working example of "onkey" so I can tailor it to my needs. The Alpha help on the subject doesn't show a complete example. Or maybe someone knows a better way to build this mousetrap, like appending ctrl-enter to the scanned data. The scanners I've looked at only take one suffix character, with some being control characters, like control-F9 and most all other keys, but no control enter. .

      Comment


      • #4
        Re: OnKey Events

        I'm thinking that you might use a second field. To capture the plus sign. You haven't told us what field has focus when the user scans the plus sign. You haven't told us whether the onKey event fires, at all, when the scanner supplies text to a field. You haven't told us if entering a plus sign from the keyboard will run your script with good results.

        Here's a complete script to see if the event fires when you're expecting...

        Code:
        IF a_user.key.value = "+" THEN
            a_user.key.handled = .T.
            IF a_user.key.event = "down" THEN
                 msgbox("Hoorah","the onkey event script just fired")
            END IF
        END IF
        Last edited by Tom Cone Jr; 05-04-2010, 03:54 PM.

        Comment


        • #5
          Re: OnKey Events

          the scanner can be programmed to do this automatically - but how do you handle when the buyer is getting several of the same item? scan serveral times?

          If the default quantity is one (should be), then just have the scanner send an ENTER or cr-linefeed and it will auto save the record and go to the next row in the browse. I do this all the time with barcode scanners.
          Cole Custom Programming - Terrell, Texas
          972 524 8714
          [email protected]

          ____________________
          "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

          Comment


          • #6
            Re: OnKey Events

            IF a_user.key.value = "+" THEN
            a_user.key.handled = .T.
            IF a_user.key.event = "down" THEN
            msgbox("Hoorah","the onkey event script just fired")
            END IF
            END IF

            Tom... This code doesn't work because, in it, the variables haven't been declared. I'd appreciate it if you'd write DIMs in the code for me. I did declare the variables, and then saved it as a Barcode field onArrive event in field rules. But when it did fire, I got a message about the variable frame being bad. To answer your questions, the barcode field has the focus and has not been saved yet when onkey should fire.

            Martin... {Enter} simply puts the focus on the next column of the grid. I haven't tried appending {ctlf} in the scanner yet, but I will. It makes better and much more efficient sense, if it works as you say. But, when we begin a new invoice, we press control-e, then we scan a barcode on the pick ticket to populate the header portion of a new invoice. This cuts down on typos. Then we save it and begin work in the line items subform. Won't the scanner save and create a new invoice record? That's not a good thing since we want to go to the first just-created record's empty subform. Which is why using onKey may be the better option, since the onKey fires only in the subform.

            I really thank both of you guys.

            Comment


            • #7
              Re: OnKey Events

              Burt -

              It is difficult to understand where your onkey code is placed. Can you describe in detail where the code is or upload a sample database demonstrating the error?

              From your description I am gathering that your code is placed in the field rules events tab, which will not work. OnKey events need to reside in the context of the form.

              http://support.alphasoftware.com/alp...s_on_forms.htm
              Andrew

              Comment


              • #8
                Re: OnKey Events

                Thanks for the tip! I moved the code to the subform's onArrive event in properties. When gave the subform focus, I was told that a_user couldn't be found. Do I have to declare it first?

                Comment


                • #9
                  Re: OnKey Events

                  I do not think you need to dim the variable first, but then I could be wrong. Can you upload a sample of the database and step by step instructions as to what your doing to generate the error? I can take a look at it tonight once I get home.
                  Andrew

                  Comment


                  • #10
                    Re: OnKey Events

                    I moved the code to the subform's onArrive event in properties
                    Onkey scripts/code should be placed on the onkey event, no other. The onkey event fires

                    Whenever a key is pressed while the form has focus.
                    The onarrive event will only fire (once) when an object gets focus.
                    There can be only one.

                    Comment


                    • #11
                      Re: OnKey Events

                      here is a sample adb showing 2 uses for the onkey event
                      I haven't had time to test the scan field, but should work - presuming the scanner sent a cr/line feed at the end of the scan
                      Cole Custom Programming - Terrell, Texas
                      972 524 8714
                      [email protected]

                      ____________________
                      "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                      Comment


                      • #12
                        Re: OnKey Events

                        Tom... This code doesn't work because, in it, the variables haven't been declared. I'd appreciate it if you'd write DIMs in the code for me. I did declare the variables, and then saved it as a Barcode field onArrive event in field rules. But when it did fire, I got a message about the variable frame being bad. To answer your questions, the barcode field has the focus and has not been saved yet when onkey should fire
                        Burt, the code runs fine as presented, but it has to be attached to the onKey event in the form layout. Since you were asking for help with a script for the onKey event I presumed you knew where to attach the script I supplied. If you're still struggling with this send me a private email. -- tom

                        ps. a_user is a system variable. You should NOT be dimming it in your script. Nor is it dimmed in the example provided in the helps.

                        Comment


                        • #13
                          Re: OnKey Events

                          Understood, Tom. I need to attach the script to the parent form's onKey event, not the subform's onArrive event, which I thought was the logical place. I did this. It works. I appreciate your help.

                          Comment

                          Working...
                          X