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

Field Lookup value on Form

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

    Field Lookup value on Form

    As with most, I think, I dislike the required field field rule so I code my own when a Save button is pushed. I'm still trying to understand when I need to use val() and when not. (I can't seem to find Selwyn's good article on that.) In the attached app, there is a very simple form, dtlsform, with one field on it, Bank_id. This is a lookup into the bank_accts table. I have discovered a grave misunderstanding on my part. I have always tested the form field value on these type lookups. When I changed my code to val(form field.text), it always seems to return zero. So I suppose I need to be testing table.field. The attached app form has two buttons, one testing the form field value which returns zero, and the other testing the underlying table value which returns the correct value. Is this the way it is supposed to work? I would like some clarification.
    Thanks.
    Ernie

    #2
    Re: Field Lookup value on Form

    You have the invent_details bank_id field defined as a lookup storing the bank_id from bank_accts bank_id but displaying the bank_name, I think.

    The underlying table field contains the bank_id (1 here for Chase) but the form display text is "Chase". Val("Chase") is 0. Table field content is 1.
    There can be only one.

    Comment


      #3
      Re: Field Lookup value on Form

      Stan,
      Thanks for your response. Yes, it was my mistake to think the form field was somehow storing the actual id number and displaying the text/name value. I think I got that idea from a previous programming language. Will have to go through my code and change all this to reference the table values for numeric type fields.
      Thanks again.
      Ernie

      P.S. Now this is screwy.... Just went back in and changed my code on the form value button to read the form field.value instead of the form field.text because I think in debugging this, I was getting that LONG number when the field is zero, (.17900000000000.....). Now it's reading one, just like the table.value. What are you seeing???

      Comment


        #4
        Re: Field Lookup value on Form

        When you say

        Code:
        vValue = val(parentform:bank_id.text)
        You're telling Alpha Five to do the following:

        a) Find the object named "bank_id" in the current form.
        b) Find the Text property of the "bank_id" object
        c) Then pass the TEXT string you just found to the VAL() function.
        d) Since the TEXT string you passed to the VAL() function does not begin with a numeric digit, VAL() returns a zero.

        working as designed. In this case the "Bank_id" object contains the bank name, while in the underlying table the "Bank_id" field in the table contains the bank id number. The Text property of the Bank_id object in your layout is different from the Value property of the Bank_id object in your layout.

        See the attached screen shot created from the Object Explorer

        Comment


          #5
          Re: Field Lookup value on Form

          Tom,
          So if I wanted to test whether or not the form field had been filled in, I could use:
          Code:
          if isblank("bank_id") then
              do whatever
          end if
          The particular form I am working with is using conditional objects, so there are about 6 bank_id objects on the form depending on a value in a multistate button. I usually refer to particular objects on the form by their object name, i.e. bank_id0, bank_id1, etc. In the isblank() function, I can use the basic field name, i.e. bank_id????? I guess the isBlank() function is referring to the underlying table field and not the form field.
          Ernie

          Comment


            #6
            Re: Field Lookup value on Form

            I guess the isBlank() function is referring to the underlying table field and not the form field.
            That's the way the function is defined.

            Result_Flag as L = ISBLANK( Field_Name as C )
            I believe you can use isblank with other types.

            Code:
            if isblank("bank_id.value") then 'bank_id0.value, etc
                do whatever
            end if
            There can be only one.

            Comment


              #7
              Re: Field Lookup value on Form

              Stan,
              It does work with any field type but also says to use isnull() to test for blank strings. I'm getting a clearer picture of all this, if I can just remember it.
              Thanks again for your help.
              Ernie

              Comment


                #8
                Re: Field Lookup value on Form

                Apparently you can isblank() variables, not sure about form objects. Just a point of interest.
                There can be only one.

                Comment


                  #9
                  Re: Field Lookup value on Form

                  Ernie, you are not understanding the concept of object properties.

                  To extend what I gave you before you would not do this:

                  Code:
                  if isblank("bank_id") then
                      do whatever
                  end if
                  You'd do this

                  Code:
                  if len(alltrim(parentform:bank_id.text)) = 0 then
                      do whatever
                  end if
                  This tells Alpha Five:

                  - find the bank_id object in the current form
                  - find its text property
                  - trim the text property of all blanks
                  - examine the length of the trimmed string
                  - if its zero then do your processing

                  The code snippet you proposed has nothing to do with what I was showing you about the text and value properties of the object in your form layout.

                  This is confusing for many people.

                  Xbasic has commands that permit your script to talk directly to the table beneath your form. It has other commands that permit your script to intereact with the GUI... with the objects in your layout which are displaying field values from the table. These objects are different from the fields in your table. Many people seem to think they're the same thing. I suspect you are making this mistake. The object in your form layout that displays a field value from your table is a completely different (separate) thing than the record buffer in memory that contains the current field value.

                  Later ...
                  Code:
                  t = table.current()
                  my_fld_value = t.my_fld     'uses methods talking directly to the table
                  
                  my_fld_text_property = parentform:my_fld.text   'uses property of the object
                  These normally produce the same result. In your case, because you've defined a coded lookup in field rules, the actual table field value is one thing, but the displayed value in the OBJECT in the form is another.

                  Is this getting clearer?
                  Last edited by Tom Cone Jr; 03-11-2010, 02:22 PM.

                  Comment


                    #10
                    Re: Field Lookup value on Form

                    Thanks, Stan.
                    Ernie

                    Comment


                      #11
                      Re: Field Lookup value on Form

                      Tom,
                      Sorry, your post hadn't appeared when I last responded to Stan. Yes that does make sense. I've been a little hesitant to use table field values while in enter mode. For some reason, I had in the back of my mind they weren't really available until the record had been saved. It is becoming clearer.
                      However:
                      if len(alltrim(parentform:bank_id.text)) = 0 then
                      So if there is no text in the field, alpha may see spaces as not being blank? The ID field is n, 16. Nothing has been selected, but I would still need to trim the nothing? It would not interpret that as being blank?

                      Ernie

                      Comment


                        #12
                        Re: Field Lookup value on Form

                        So if there is no text in the field, alpha may see spaces as not being blank? The ID field is n, 16. Nothing has been selected, but I would still need to trim the nothing?
                        No I suppose not. I guess I've been thinking that your data type was CHARACTER. For character data it's difficult to know there's no text in the object. The blank spaces a user enters with the spacebar count as "text", but are invisible. I guess you could make a multi-step sequence in which the script checks the length of the "text" in the text property of the object, and then checks further to see if the text only consists of invisible blank spaces if you want. Your script could then branch if the untrimmed length is zero or if the string only contains "blanks". For me, it's simpler to trim whatever's there and check the length of the trimmed string. Over the years I've seen lots of instances where the user inadvertantly presses the spacebar and inserts a blank space into a field. I've learned the hard way that it's a mistake to assume that there's "real" data in the field simply because the untrimmed length of the text string is greater than zero.

                        In the case of a numeric field this shouldn't be necessary cause I don't think the user can enter any blanks into such a field in the first place, right?

                        Good luck with your project.

                        -- tom
                        Last edited by Tom Cone Jr; 03-12-2010, 09:21 AM.

                        Comment


                          #13
                          Re: Field Lookup value on Form

                          Thanks, Tom. I guess that is why the help file says for character fields, use the isnull() function. Thanks for the tips on what you've learned the hard way. Seems no matter how tight you think you have your code, some user will figure out a way to break it. But that's just part of the process in writing programs.
                          Thanks again for all your help in my education process.
                          Ernie

                          Comment

                          Working...
                          X