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

"No such field" error in an append operation

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

    "No such field" error in an append operation

    I modified a correct working function without an argument

    Code:
    FUNCTION stat01 AS C ( )
    .
    .
    append.t_filter = "DocYear=year(date())-1"
    .
    .
    into a function with an argument:

    Code:
    FUNCTION stat01 AS C (vyear as N)
    .
    .
    append.t_filter = "DocYear=vyear"
    .
    .
    I now get the error message: No such field (errorcode = 1003)


    I also tried
    Code:
    append.t_filter = "DocYear=var->vyear"
    but then the errorcode is 1527


    Who can help me with the correct syntax for pointing to the argument?

    Thanks

    Ton
    Most things are simple but unfortunately only after the first time

    #2
    Re: "No such field" error in an append operation

    I think you want

    append.t_filter = "DocYear="+alltrim(str(vyear))

    I don't believe you need the alltrim(str()) due to Alpha's automatic type conversion when appending to a character string but it does make it clearer what you are doing.
    There can be only one.

    Comment


      #3
      Re: "No such field" error in an append operation

      Hi Stan,

      Thanks for your quick reply but unfortunately the syntax is incorrect.

      As you could see in the correct working function, the fields are numeric.
      If the value was in an global variable I could point to var->GlobalNumericValue.

      But I cannot imagine there is no way to point to the argument. Maybe in combination with 'eval'.

      If there is no other way, I must use that intermediate step.

      A curious puzzle.
      I wonder who can solve it.

      Ton
      Most things are simple but unfortunately only after the first time

      Comment


        #4
        Re: "No such field" error in an append operation

        As you could see in the correct working function, the fields are numeric.
        But the append.filter must be a character expression, n'est pa?

        Code:
        vyear = 2007
        
        append.t_filter = "DocYear=var->vyear"
        ? append.t_filter
        = "DocYear=var->vyear"
        
        append.t_filter = "DocYear="+alltrim(str(var->vyear))
        ? append.t_filter
        = "DocYear=2007"
        There can be only one.

        Comment


          #5
          Re: "No such field" error in an append operation

          Originally posted by Stan Mathews View Post
          But the append.filter must be a character expression, n'est pas?
          Oui monsieur, tres bien.

          As said this is the intermediate step and will work.

          Code:
          FUNCTION stat01 AS C (vyear as N )
          DIM global myyear as N =  vyear
          .
          .
          append.t_filter =  "Docyear=var->myyear"
          .
          .
          delete global myyear

          I have a similar argument like this for the sum.filter in a summarize function without any problem

          Code:
          sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=vyear"
          Thats why I still want(ed) to find a solution for the append.t_filterexpression to point direct to the argument of the function.
          I am afraid there isn't.

          Merci

          Ton
          Most things are simple but unfortunately only after the first time

          Comment


            #6
            Re: &quot;No such field&quot; error in an append operation

            Here are 2 more examples both producing error code 1091 field types don't match
            How do you use alltrim etc when multiplying 2 variables within brackets?

            'global variables declared as form variables when form opened
            SSCtemp (should = 121.32 when calculated in code below)
            Var->Uppwemp = 2022 (calculated before running code below)
            var->Ratemp = 6.0 (calculated before running code below)

            This code is called from a script run within xbasic code from a button on a form
            SSCtemp=(Var->Uppwemp*var->Ratemp)/100
            When run error 1091 field types don't match occurs

            Here Ssc_normal is a table field, following code should set the field's value to 121.32
            parentform:Ssc_normal.value = (Var->Uppwemp*var->Ratemp)/100
            again, When run error 1091 field types don't match occurs

            Comment


              #7
              Re: &quot;No such field&quot; error in an append operation

              Hi Mike,

              It's a different case what you bring up now.
              Please debug your Xbasic and test the variables and fields with typeof() then you can discover which field has different filetype as you expected.

              ? typeof(SSCtemp)

              If SSCtemp is a Characterfield, then your calculation can be: SSCtemp= alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2))

              In my interactive window:

              dim uppwemp as N = 2022
              dim Ratemp as N = 6.0
              ?? uppwemp
              2022
              ?? Ratemp
              6

              SSCtemp = alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2))
              ?? SSCtemp
              "121.32"

              OR

              SSCtemp = stritran(alltrim(str(Var->Uppwemp*var->Ratemp/100,12,2)),".",",")
              ?? SSCtemp
              "121,32"



              Good luck

              Ton
              Most things are simple but unfortunately only after the first time

              Comment


                #8
                Re: &quot;No such field&quot; error in an append operation

                Many thanks for your advice Ton. I hadn't come across typeof before - very useful

                SSCtemp is a numeric global variable. I think I've got the first example working. I added 'var->' in from of the SSCtemp code and it now seems OK.

                Mike

                Comment


                  #9
                  Re: &quot;No such field&quot; error in an append operation

                  I opened AlphaSports and duplicated the Customer table, no records, no indexes, etc. (named the duplicate app_cust)
                  I entered some records in the duplicate table and gave one of the records a creditrating of 9.
                  I created a function to append records from the duplicate table to the customer table with the filter of creditrating > function_parameter.

                  Code:
                  FUNCTION app_cr AS L (cr_rate AS N )
                  app_cr = .F.
                  DIM Append as P
                  a_tbl = table.open("Customer")
                  append.t_db = "app_cust"
                  ON ERROR GOTO ERROR23112011073425989
                  append.m_key = ""
                  append.t_key = ""
                  append.m_filter = ""
                  append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
                  append.type = "All"
                  append.m_count = 21
                  append.m_field1 = "CUSTOMER_ID"
                  append.m_exp1 = "@APP_CUST->CUSTOMER_ID"
                  append.m_field2 = "FIRSTNAME"
                  append.m_exp2 = "@APP_CUST->FIRSTNAME"
                  append.m_field3 = "LASTNAME"
                  append.m_exp3 = "@APP_CUST->LASTNAME"
                  append.m_field4 = "COMPANY"
                  append.m_exp4 = "@APP_CUST->COMPANY"
                  append.m_field5 = "PHONE"
                  append.m_exp5 = "@APP_CUST->PHONE"
                  append.m_field6 = "FAX"
                  append.m_exp6 = "@APP_CUST->FAX"
                  append.m_field7 = "BILL_ADDRESS_1"
                  append.m_exp7 = "@APP_CUST->BILL_ADDRESS_1"
                  append.m_field8 = "BILL_ADDRESS_2"
                  append.m_exp8 = "@APP_CUST->BILL_ADDRESS_2"
                  append.m_field9 = "BILL_CITY"
                  append.m_exp9 = "@APP_CUST->BILL_CITY"
                  append.m_field10 = "BILL_STATE_REGION"
                  append.m_exp10 = "@APP_CUST->BILL_STATE_REGION"
                  append.m_field11 = "BILL_POSTAL_CODE"
                  append.m_exp11 = "@APP_CUST->BILL_POSTAL_CODE"
                  append.m_field12 = "BILL_COUNTRY"
                  append.m_exp12 = "@APP_CUST->BILL_COUNTRY"
                  append.m_field13 = "SHIP_ADDRESS_1"
                  append.m_exp13 = "@APP_CUST->SHIP_ADDRESS_1"
                  append.m_field14 = "SHIP_ADDRESS_2"
                  append.m_exp14 = "@APP_CUST->SHIP_ADDRESS_2"
                  append.m_field15 = "SHIP_CITY"
                  append.m_exp15 = "@APP_CUST->SHIP_CITY"
                  append.m_field16 = "SHIP_STATE_REGION"
                  append.m_exp16 = "@APP_CUST->SHIP_STATE_REGION"
                  append.m_field17 = "SHIP_POSTAL_CODE"
                  append.m_exp17 = "@APP_CUST->SHIP_POSTAL_CODE"
                  append.m_field18 = "SHIP_COUNTRY"
                  append.m_exp18 = "@APP_CUST->SHIP_COUNTRY"
                  append.m_field19 = "SHIP_SAME"
                  append.m_exp19 = "@APP_CUST->SHIP_SAME"
                  append.m_field20 = "EMAIL"
                  append.m_exp20 = "@APP_CUST->EMAIL"
                  append.m_field21 = "CREDITRATING"
                  append.m_exp21 = "@APP_CUST->CREDITRATING"
                  append.t_count = 0
                  a_tbl.append()
                  GOTO CONTINUE23112011073425989
                  ERROR23112011073425989:
                  ON ERROR GOTO 0
                  ui_msg_box("Error","Error running Append Operation"+crlf()+error_text_get())
                  END
                  CONTINUE23112011073425989:
                  a_tbl.close()
                  app_cr = .T.
                  END FUNCTION
                  The function is executed like app_cust(6). It works.
                  Note that if the filter is stated as

                  append.t_filter = "Creditrating > cr_rate"

                  it will not work.

                  app_cust.zip
                  app_cr - 11-23-2011 -1.txt
                  There can be only one.

                  Comment


                    #10
                    Re: &quot;No such field&quot; error in an append operation

                    Hi Stan,

                    Thanks for confirming. Great job to test this case as you did.
                    Weird that it is more a quest ' Find the right syntax' than logic programming.
                    But I like the workaround you provided. Very elegant.

                    Ton
                    Most things are simple but unfortunately only after the first time

                    Comment


                      #11
                      Re: &quot;No such field&quot; error in an append operation

                      suggesting that this syntax

                      Code:
                      append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
                      is a 'work around' for this syntax

                      Code:
                      append.t_filter = "Creditrating > cr_rate"
                      not working is, in my opinion, misleading because it implies that the second syntax SHOULD have worked.

                      the first syntax shown here is correct. it is not a work around because the second syntax should not have worked.

                      the append.t_filter property is a character string that contains a filter expression.

                      say you want the filter to be: state = "MA"
                      and say you have a variable called 'whatState'

                      clearly if you write

                      Code:
                      append.t_filter = "state = \"ma\""
                      it is clear what you intend.

                      if you write

                      Code:
                      append.t_filter = "state = var->whatState"
                      it is clear that this is not the same as: state = "MA"

                      but

                      Code:
                      append.t_filber = "state = " + s_quote(whatState)
                      is obviously the same as

                      Code:
                      state = "MA"
                      which is what you intended the filter to be.

                      Comment


                        #12
                        Re: &quot;No such field&quot; error in an append operation

                        Originally posted by Selwyn Rabins View Post
                        suggesting that this syntax

                        Code:
                        append.t_filter = "Creditrating > "+alltrim(str(cr_rate))
                        is a 'work around' for this syntax

                        Code:
                        append.t_filter = "Creditrating > cr_rate"
                        not working is, in my opinion, misleading because it implies that the second syntax SHOULD have worked.

                        the first syntax shown here is correct. it is not a work around because the second syntax should not have worked.

                        the append.t_filter property is a character string that contains a filter expression.
                        Selwyn,

                        Thank you for your explanation.
                        The reason I was thinking it should work is here in this line
                        Code:
                        sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=vyear"
                        where vyear is a numeric variable passed as argument into a function with this append-operation.

                        Remaining question: Is (focused on a numeric variable) the syntax of 'sum.filter' different than 'append.t_filter'?

                        Ton
                        Most things are simple but unfortunately only after the first time

                        Comment


                          #13
                          Re: &quot;No such field&quot; error in an append operation

                          in some cases, if the scope of the variable is global or session, a5 will attempt to resolve a filter string that contains a variable. it is possible that the example you are referencing used a global or shared (session) variable.

                          however, i don't like this at all - and if it were not for the fact that we don't want to break any existing application that rely on this behavior, i would be tempted to remove this behavior.

                          i think it is much more understandable if you resolve the variable reference yourself, as in:

                          Code:
                          sum.filter = ".NOT.ISBLANK(\"Customer\").AND.NUMBER<>5.AND.Docyear=" + s_quote(vyear)
                          rather than rely on a5 to try (and sometimes fail) to resolve the variable reference.

                          Comment


                            #14
                            Re: &quot;No such field&quot; error in an append operation

                            in some cases, if the scope of the variable is global or session, a5 will attempt to resolve a filter string that contains a variable. it is possible that the example you are referencing used a global or shared (session) variable.
                            Thank you for that.

                            I was at a loss to try to explain why sometimes the "Creditrating > cr_rate" syntax would work and sometimes not. I could not resolve whether it was the context or something else that allowed it to work. In this instance, moving from a script where it worked to a function where the passed paramater did not work, further clouded the issue for me.

                            I'd be hard pressed to work out how this should be added to the wiki, but it should be.
                            Last edited by Stan Mathews; 11-25-2011, 06:53 PM.
                            There can be only one.

                            Comment


                              #15
                              Re: &quot;No such field&quot; error in an append operation

                              Discovered inconsistencies divide people into two camps. Both prove their right to enjoy the benefits and do not know about the existence of the other.

                              Selwyn thanks for your clarification. Very instructive.

                              Ton
                              Last edited by Ton Spies; 11-25-2011, 06:31 PM. Reason: better translation
                              Most things are simple but unfortunately only after the first time

                              Comment

                              Working...
                              X