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

find by phone number, no records found

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

    find by phone number, no records found

    I would like to be able to have a push button to search by phone number. I want it to prompt user for phone number, but I only want it to retrieve the records that contain the phone number. And if no phone number is found I would like for it to say "no records found" and show NO records.

    Would someone point me in the right direction please?

    I currently have a find by key, but it doesn't tell you taht no records have been found. And if it does find the phone number, you keep pressing arrow down and it moves to the next record, which doesn't contain the number.

    Thanks in advance for any help
    Kathy

    #2
    RE: find by phone number, no records found

    Here's one way. I didn't add any code to preserve the original order of records and restore it after.

    Open AlphaSports, Edit the Customer Information form, create a new button, use xbasic editor, and put this in the code box, save, etc.

    tbl = table.current()
    tbl.fetch_first()
    findnum = ui_get_text("Which","Enter the number without () or - or spaces")
    findnum = mask(findnum,"( )| - ")
    query.order = "phone"
    query.filter = "alltrim(Phone) = "+quote(findnum)
    ix = tbl.query_create()
    countnum = ix.records_get()
    if countnum " 0
    parentform.Refresh_Layout()
    else
    ui_msg_box("Sorry","No records found")
    end if
    parentform.Show_All()
    There can be only one.

    Comment


      #3
      RE: find by phone number, no records found

      Note that Stan's routine shows ALL records if none are found. This is probably the best way to do it because "showing no records" will actually put the form into Enter mode just like opening a new table with nothing in it - probably not what you want to do.

      I suppose you might be able to get away with this if the form is Read-only or if "Enter" is restricted but it may create other problems. I've never tried this so I'm not sure but I would definitely check it carefully before letting anyone use it that way.

      Comment


        #4
        RE: find by phone number, no records found

        I pasted this exactly from your post and when I enter a phone number it always says no records found. Do I need to do something else? Also if you have time would you tell me in english what each line is doing, so I can understand. Thanks for your help, I'm new but learning!
        Kathy

        Comment


          #5
          RE: find by phone number, no records found

          Pasted it where? The script given is specific to the AlphaSports customer information form, designed to be the onpush event code for a new button.

          tbl = table.current() 'get pointer to current table
          tbl.fetch_first() 'go to the first record
          findnum = ui_get_text("Which","Enter the number without () or - or spaces") 'ask the user for a phone number in the format ##########
          findnum = mask(findnum,"( )| - ") 'transform the ########## into (###) ###-#### which is the way the numbers are stored in the AlphaSports customer table
          query.order = "phone" 'create the order expression for a query, phone the field name in the table containing phone numbers
          query.filter = "alltrim(Phone) = "+quote(findnum) 'create the filter expression for a query
          ix = tbl.query_create() 'run the query against the AlphaSports customer table, creating a pointer
          countnum = ix.records_get() 'get the number of records returned by the query
          if countnum " 0 'if the number of records is greater than zero
          parentform.Refresh_Layout() show the first record matching the query on the form
          else 'else
          ui_msg_box("Sorry","No records found") 'display message no records found
          end if 'end the if
          parentform.Show_All() 'release the query

          If you try to use this on a table of yours you will have to modify the lines

          findnum = ui_get_text("Which","Enter the number without () or - or spaces")
          findnum = mask(findnum,"( )| - ")
          query.order = "phone"
          query.filter = "alltrim(Phone) = "+quote(findnum)

          to suit your needs.

          Or you could just attach a sample of your table so I can see how it is set up, as the "Please read before posting" thread at the top of the post listing suggests.
          There can be only one.

          Comment


            #6
            RE: find by phone number, no records found

            I pasted it where you said to with in Alpha sports.
            Here is the error I get:

            Script::customer_information:BUTTON1.on push line 7:
            ix=tbl.query_create()
            No such field

            Comment


              #7
              RE: find by phone number, no records found

              Can't imagine what the difference might be. I have attached a zip of my version of the customer table files from AlphaSports. If you unzip it to the location of your AlphaSports database, it should contain everything you need to see how the button works on the form. Button is in the top right, dark blue, label is just "script".
              There can be only one.

              Comment


                #8
                RE: find by phone number, no records found

                Stan -

                Yes, your example code works fine. I'm seeing a similar error to Kathy's when trying this with my APP (see attached screen shot). It seems to center around the line:

                ix=table.query_create()

                Is "ix" a variable that has to be declared explicitly?

                Thanks,

                Dave

                Comment


                  #9
                  RE: find by phone number, no records found

                  David,

                  Your error message suggests a syntax error in the query.filter expression.

                  the table.query_create() method will return a pointer to the query list when it runs successfully. "ix" is simply a variable to hold the pointer returned by the method. It need not be declared explicitly unless your script uses OPTION STRICT.

                  -- tom

                  Comment


                    #10
                    RE: find by phone number, no records found

                    Tom -

                    Thanks for the reply. Here is the code I have "ONPUSH"

                    'Date Created: 18-Jul-2005 03:19:19 PM
                    'Last Updated: 24-Jul-2005 11:58:54 AM
                    'Created By : Stan Mathews
                    'Updated By : Dave
                    tbl = table.current()
                    tbl.fetch_first()
                    findnum = ui_get_text("Which","Enter the number without () or - or spaces")
                    findnum = mask(findnum,"( )| - ")
                    query.order = "recid"
                    query.filter = "alltrim(recid) = "+quote(findnum)
                    ix = tbl.query_create()
                    countnum = ix.records_get()
                    if countnum " 0
                    parentform.Refresh_Layout()
                    else
                    ui_msg_box("Sorry","No records found")
                    end if
                    parentform.Show_All()

                    Where "recid" is a 10 character numeric field in the current table. What might I be missing?

                    -Dave

                    Comment


                      #11
                      RE: find by phone number, no records found

                      Post a working copy of your database, with instructions for us to follow to see the problem. I'm suspicious of the data types you're using in the filter expression. It's not clear you understand their data types either. RecId cannot be a character numeric field. It's one or the other, right?

                      -- tom

                      Comment


                        #12
                        RE: find by phone number, no records found

                        Tom -

                        Clarification: "Recid" is a 10-numeral numeric field. I'll prepare a working copy so you can see what I'm doing. Thanks.

                        -Dave

                        Comment


                          #13
                          RE: find by phone number, no records found

                          Tom -

                          OK, take a look at this. From the main menu, go to "add/edit records' then you'll see a push button on the botom to "search recrod ID". Recid is a 10 digit numeric field. I still get the before mentioned error with this example database. Any thoughts on what's wrong apprecitated.

                          -Dave

                          Comment


                            #14
                            RE: find by phone number, no records found

                            I'm not sure why you'd be storing a phone number as a numeric type, if that is what you are doing. The expression

                            query.filter = "alltrim(recid) = "+quote(findnum)

                            would be

                            query.filter = "recid = "+findnum

                            for a numeric field.

                            The common usage is to use numeric fields only if you intend to do computations involving the contents. Using character fields to store such strings of digits lends itself to much easier parsing if you want a subset such an area code, the "plus four" of a zip code, etc.
                            There can be only one.

                            Comment


                              #15
                              RE: find by phone number, no records found

                              Get rid of

                              findnum = mask(findnum,"( )| - ")


                              as well. I don't imagine Alpha lets you mask a number.
                              There can be only one.

                              Comment

                              Working...
                              X