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

Automatic Lookup for a default value in Forms

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

  • Automatic Lookup for a default value in Forms

    Once I get this in the most efficient manner, I have at least 70 to do on a similar basis.
    Ok, V9 Paltinum Desktop...
    I have a form:
    On the form is the following:
    County Name called DLRCNTY.
    County ID called CNTYNO. It is Char as it can be 001..009...010...290.

    When the user enters the DLRCNTY value, ex: "HARRIS"
    Then the next field is CNTYNO.
    I want the CNTYNO filled in by fetching (Looking up) the correct CNTYNO from a "Library" dbf called "county.dbf"
    It is indexed by its field called "COUNTY_NAME" and has the value I want in CNTY_NO.
    So, "on arrival" in the form at CNTYNO, the program does a lookup, using the previous field (DLRCNTY) value.
    a lookup would be:
    lookup"county.dbf","COUNTY_NAME="+DLRCNTY,"CNTY_NO")
    Literally:
    lookup("county.dbf","COUNTY_NAME='HARRIS'","CNTY_NO")
    1.
    First Love

  • #2
    Re: Automatic Lookup for a default value in Forms

    Hi Tom,

    Why do yo want to do a second lookup when you can fill all the fields you want from the first lookup?

    From what you are describing everything is in the "County" table.

    Unless I'm missing something and what you want to do is a filtered lookup for the second field.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    Comment


    • #3
      Re: Automatic Lookup for a default value in Forms

      I'm with Keith. Why not use a table lookup field rule on the DLRCNTY field, and define it in such a way as to "autofill" the CNTY_NO field?

      Comment


      • #4
        Re: Automatic Lookup for a default value in Forms

        Originally posted by Keith Hubert View Post
        Hi Tom,

        Why do yo want to do a second lookup when you can fill all the fields you want from the first lookup?

        From what you are describing everything is in the "County" table.

        Unless I'm missing something and what you want to do is a filtered lookup for the second field.
        Ok, Keith,
        Let's stick with the 1st lookup that gets the CNTYNO from the county dbf.
        (The 2nd one is for use on other forms or operations where the CNTYNO is known, but not the DLRCNTY. So we'll let that rest for now.)

        If I understand, the consensus is that I should forget the lookup at the form level and place it at the DTA.DBF table level with a field rule.
        i.e. "This is usually done in the table's field rules, not as event code for a form."
        Ok,
        My ancient progamming taught that the base table should be a simple as possible with no calculations where possible.
        I'll have to change my thinking.
        So, I went back to the DTA.DBF table and did the field rule using the function I posted.
        It works just fine now on the FORM, even though that CNTYNO field is no longer editable by the user. So it's really not a default, but a Calc'd field only.
        If no edit possible, I'll live with that for now, at least in this particular FORM.
        If there is any other lookup alternative ways of writing the FUNCTION I posted, feel free to offer them.
        In the meantime, thank you all for your productive help. This Forum is what keeps me encouraged to stay with A5. Oh. and the many Videos and books like Xbasic for Everyone, A5 Functions manual, and when I get better at it I want to add the Code Utility program to see if it can speed up my production.

        Best to all,
        Tom
        Last edited by SMARTII; 04-21-2009, 12:41 PM.
        First Love

        Comment


        • #5
          Re: Automatic Lookup for a default value in Forms

          BTW:
          The first post chopped off the FUNCTION I wrote at least I can't see it:

          FUNCTION cntylups AS C (sndval AS C,which as c)
          DIM RTNFLD AS C
          DIM SNDFLDVAL AS C
          '------------
          if which = "id"
          SNDFLDVAL = "COUNTY_NAME = " + S_QUOTE(SNDVAL)
          RTNFLD = "CNTY_NO"
          elseif which = "name"
          SNDFLDVAL = "CNTY_NO = " + S_QUOTE(SNDVAL)
          RTNFLD = "COUNTY_NAME"
          else
          SNDFLDVAL = "COUNTY_NAME = " + S_QUOTE(SNDVAL)
          RTNFLD = "CNTY_NO"
          cntylups = "need which"
          exit function
          end if
          cntylups = alltrim(lookup("COUNTY.DBF",SNDFLDVAL,RTNFLD))
          END FUNCTION
          First Love

          Comment


          • #6
            Re: Automatic Lookup for a default value in Forms

            Tom, perhaps it's me. But maybe you're misunderstanding the advice thus far. Instead of defining a calculated field that uses a lookup function to retrieve the desired field value, why not make both fields user entered, but define a table lookup field rule. This will give you the opportunity to lookup the county from a popup (or drop down) list, assuring no typo errors, and will let you "autofill" the related county number field. Take a look at the topic "Creating a Table Lookup" in the User Guide.

            Comment


            • #7
              Re: Automatic Lookup for a default value in Forms

              Tom C,
              I believe Tom M want it automatic, without user selection derived from one field imput... kind of.

              Tom M,
              You have me confused. The first post said you wanted to achieve a value for the county number field (CNTYNO) from the value of the county name field (DLRCNTY) by a lookup to the COUNTY table using the county name as the filter. The function you wrote has parameters that allow either name or id to be used. It reads like it should work, if you populate the parameters appropriately, which is not part of the function and must be passed to the function somehow. So, what is you question/issue/problem, now?
              Mike W
              __________________________
              "I rebel in at least small things to express to the world that I have not completely surrendered"

              Comment


              • #8
                Re: Automatic Lookup for a default value in Forms

                Mike W, you may be right. But at the top he said:
                When the user enters the DLRCNTY value, ex: "HARRIS"
                I've found that picking a name from a list is much more reliable than asking the user to type it in from scratch. Consider the problem a subsequent calc expression will have if the user mistypes...

                Much better to ask user to pick the county name right off the lookup list and avoid typing altogether.

                Comment


                • #9
                  Re: Automatic Lookup for a default value in Forms

                  I also like the idea of a pick list using the county table. But in this ONE case/form the county is always the "home" county of the user's company, so it would probably just get typed in faster. I may even set it to default to that based on the zipcode they enter before the county name.

                  HOWEVER, later on, in the sales DBF / Form the buyer's county could be any one of hundreds that the user may not know how to spell as 'Monongahela", "SCHLEICHER" or "NACOGDOCHES" come to mind. As well, some zipcodes are cross-county. Mine included. I get law suits all the time from the wrong county:) But I always inform them on the day before appearance.
                  The pick list will get used, but just not on this form.
                  So, as he said, 'I'll be back."

                  thanks.
                  Last edited by SMARTII; 04-21-2009, 04:19 PM.
                  First Love

                  Comment


                  • #10
                    Re: Automatic Lookup for a default value in Forms

                    Originally posted by Tom Cone Jr View Post
                    Mike W, you may be right. But at the top he said:
                    I've found that picking a name from a list is much more reliable than asking the user to type it in from scratch. Consider the problem a subsequent calc expression will have if the user mistypes...

                    Much better to ask user to pick the county name right off the lookup list and avoid typing altogether.
                    Ok, I'm back...a better A5 programmer thanks to all of you bouncing ideas off of me and each other!
                    I gave the idea of a pick list lookup at the County Name field some more thought.
                    Although the particular form, as I said has few records, I do have 2 clients (National Rental Car Co's) that have as many as 40 locations to track in this Table/Form.
                    So, when I finally got it through my head that A5 can have baskets full of operations/Code in the native table. (I was taught forever to avoid such and keep the native dbf as simply a repository of data.) things began to make sense.
                    I modified the DTA.dbf by adding a lookup to the County dbf.
                    The Lookup linked County.COUNTY_NAME->DTA.DLRCNTY. In addition I asked it to fill in the CNTYNO from the County.dbf as well.
                    Then I just opened the User FORM and Voila! As soon as the user types enough of the county name to make it unique, A5 filled in the rest of the name in the correct case, and filled in the CNTYNO as well! In addition, they can click the little "down" button on the right of the field and the whole list of counties pops up.
                    Now this won't excite anyone but me, (A5 101??) but this is a major break through in my FORM design! Actually it's the table design that makes it work. Now, since they have to have the County Tax Collector name as well, I'm adding that to the lookup auto-insert.
                    I had this down pat in my old software and now I have it here!

                    I'm trying to get this big Application done before rigor mortise sets in completely.
                    Thank you all so much. I've been a teacher/mentor for 15yrs, so it's great to be the teachee for once.
                    Tom McC
                    Last edited by SMARTII; 04-22-2009, 06:32 PM.
                    First Love

                    Comment

                    Working...
                    X