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

Argument is incorrect data type

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

    Argument is incorrect data type

    The following function will generate the "Argument is incorrect data type" error msg when the function is associated with a button on the form.

    When I run it in the "interactive" window, it runs fine!!!
    ?QP_DoesProfileExist(user_id)

    The error occurs when line 7 executes...
    "QP_DoesProfileExist = indx.records_get()"
    indx.records_get() is numeric and so is the functions return value.

    The code...
    ************************************************************
    FUNCTION QP_DoesProfileExist AS N (SelectedUserID AS C )

    tbl_dst = table.open("QuickPick_UserTabProfile")

    query.filter = "userid = SelectedUserID"
    indx = tbl_dst.query_create()
    QP_DoesProfileExist = indx.records_get()

    tbl_dst.close()

    END FUNCTION

    #2
    RE: Argument is incorrect data type

    Do you really want your query filter to be
    "userid = SelectedUserID", or do you want it to be userid = the value passed into the function? If you're after the latter, you need


    query.filter = "userid = " + SelectedUserID

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

    Comment


      #3
      RE: Argument is incorrect data type

      Yes, I would like to use the value passed into the function.

      I just substituted your syntax...

      query.filter = "userid = " + SelectedUserID

      and the query_create didn't run...
      (using the interactive window)

      indx = tbl_dst.query_create()
      ERROR: no such field

      Hubert

      Comment


        #4
        RE: Argument is incorrect data type

        I just substituted your syntax...

        query.filter = "userid = " + SelectedUserID

        and the query_create didn't run...
        (using the interactive window)

        indx = tbl_dst.query_create()
        ERROR: no such field

        Hubert


        Quotes issue, perhaps?

        query.filter = "userid="+Quote(SelectedUserId)

        ===Blake===

        Comment


          #5
          RE: Argument is incorrect data type

          Blake,

          I have tried each of the following expressions and still no luck.

          The puzzling thing is that it works in the interactive window, but not when fired off by the form button!!!

          query.filter = "userid = SelectedUserID"
          query.filter = "userid = " + SelectedUserID
          query.filter = "userid="+Quote(SelectedUserId)

          Hubert

          Comment


            #6
            RE: Argument is incorrect data type

            Blake,

            I have tried each of the following expressions and still no luck.

            The puzzling thing is that it works in the interactive window, but not when fired off by the form button!!!

            query.filter = "userid = SelectedUserID"
            query.filter = "userid = " + SelectedUserID
            query.filter = "userid="+Quote(SelectedUserId)

            Hubert

            Comment


              #7
              RE: Argument is incorrect data type

              Well, working one place and not the other suggests to me a scope issue.

              Userid is a field? If so, what happens if you qualify it with the table name, like:

              "users->userid="+Quote(SelectedUserId)

              Assuming that userid is a field and SelectedUserID contains a value to be searched for, this should work.

              You should set a breakpoint before your code that sets the filter and ensure that Query.Filter looks the way you think it should.

              Also, you might try using "lookup"; I think you could get a single lookup call to do what your function does.

              lookup("users", "userid="+Quote(SelectedUserID), "somefield")

              Comment


                #8
                RE: Argument is incorrect data type

                Doh.

                I went back and looked at your problem. I'd guess it was, in fact, this:

                QP_DoesProfileExist = indx.records_get()

                indx.records_get() will return a CHARACTER string, but your function returns a NUMERIC.

                How about:

                QP_DoesProfileExist = val(indx.records_get())

                ??

                Comment


                  #9
                  RE: Argument is incorrect data type

                  Blake,

                  "indx.records_get()" returns a type numeric, not char.

                  the function also returns a numeric.

                  The interactive window understands.

                  The runtime interpreter seems to hiccup.

                  But anyway, I just tried your example...

                  QP_DoesProfileExist = val(indx.records_get())

                  and I got what I expected... "ERROR: Argument is incorrect data type"

                  Hubert Lee

                  Comment


                    #10
                    RE: Argument is incorrect data type

                    I think this illustrates what Blake is suggesting....


                    Created a table, QuickPick_UserTabProfile, one field, userid. Entered several records.

                    Used your function and added some lines to see what was happening.

                    'Date Created: 01-Apr-2003 08:20:53 PM
                    'Last Updated: 01-Apr-2003 08:50:04 PM
                    'Created By :
                    'Updated By :
                    FUNCTION QP_DoesProfileExist AS N (SelectedUserID AS C )

                    tbl_dst = table.open("QuickPick_UserTabProfile")
                    query.filter = "userid = "+quote(SelectedUserID)
                    indx = tbl_dst.query_create()
                    filter = query.filter
                    order = ""
                    options = ""
                    description = "test"
                    show_all_flag = .f. 'user cannot turn off the query
                    layout_type = "browse" 'to open a form, set this to "form"
                    layout_name = "" 'This will open the default layout. You can also specify a named layout here
                    a5_open_layout(layout_type,layout_name,"quickpick_usertabprofile",filter,order,description,show_all_flag)
                    QP_DoesProfileExist = indx.records_get()
                    tbl_dst.close()

                    END FUNCTION

                    Created a form, button code

                    test2 = QP_DoesProfileExist(QUICKPICK_USERTABPROFILE->USERID)
                    test2.refresh()

                    Works like a charm.
                    There can be only one.

                    Comment


                      #11
                      RE: Argument is incorrect data type

                      Ya know...I thought "It should return numeric" but I would swear that right before I posted that, the auto-complete pop-ups in A5 were talling me that it returned a char. (I thought that odd, but not the oddest thing I've seen.) I also would have sworn that i tested it with the val and it worked but all traces of the character-returning-records_get function are gone so file this alongside the vanishing hitchhiker.

                      'course I'd also swear that I put three records into a bogus user database to test it and A5 just ate them, so maybe it's time to go to bed.

                      Anyway, I put in your code exactly as you posted it in your original message, only using Quote:

                      query.filter = "userid = "+Quote(SelectedUserID)

                      and it worked just fine, interactively and on a form.

                      I'd say the time has come for you to post a stripped down database presenting the problem!

                      In the meantime, if you don't need an actual count, you might try a workaround and see if you get the same problem occurring. I found this code also worked:

                      FUNCTION QP_DoesProfileExist AS N (SelectedUserID AS C )
                      tbl_dst = table.open("user")
                      s = lookup("user", "userid="+quote(SelectedUserID), Quote("1"))
                      QP_DoesProfileExist=iif(s="", 0, 1)
                      tbl_dst.close()
                      END FUNCTION

                      Comment


                        #12
                        RE: Argument is incorrect data type

                        Blake,

                        I really appreciate you hanging in there and helping me...

                        Attached is the table that the function interacts with.

                        I have tried something else...

                        I created a global numeric variable that is set inside the function. Again if I run it in the interactive, it is okay and same error when on the form. Below is my function with all the different convolutions that I have tried with simular results...
                        =================================
                        FUNCTION QP_DoesProfileExist AS N (SelectedUserID AS C )
                        'returns how many profiles this user has...

                        tbl_dst = table.open("QuickPick_UserTabProfile")

                        'query.filter = "userid = SelectedUserID"
                        'query.filter = "userid = " + SelectedUserID
                        'query.filter = "userid="+Quote(SelectedUserId)

                        query.filter = "userid = "+Quote(SelectedUserID)

                        indx = tbl_dst.query_create()

                        'indirect assignment to a global var also fails... hint???
                        'nummy = indx.records_get()
                        'QP_DoesProfileExist = nummy

                        'direct assignment... nada...
                        QP_DoesProfileExist = indx.records_get()

                        tbl_dst.close()

                        END FUNCTION
                        ===========================================

                        I just tried this one more time with same failure mode...
                        query.filter = "userid = "+Quote(SelectedUserID)

                        I think this is a real A5 problem.

                        Hubert Lee

                        Comment


                          #13
                          RE: Argument is incorrect data type

                          Stan,

                          My function is called by a button on a form.

                          The function does not open a form.

                          My argument is not the query... it is the assignment of a records_get() value (numeric) to a numeric variable or function return value.

                          Hubert

                          Comment


                            #14
                            RE: Argument is incorrect data type

                            New revelations...

                            In my application, there are several objects and vars to be intiallized.

                            So I created a new application with the bare bones minimum requirements and the function now works on both the interactive and form!!!

                            Now all I got to do is figure out what in the form OnInit event is causing the interaction...

                            I will keep you posted.

                            Hubert

                            Comment


                              #15
                              RE: Argument is incorrect data type

                              Created a form, with a button the code for which is

                              test2 = QP_DoesProfileExist(QUICKPICK_USERTABPROFILE->USERID)
                              test2.refresh()

                              The rest of the additions I made to your function were merely to display a browse of the records qualifying the query while I was testing.

                              What are you doing with the returned value? I was showing it on the form by placing a variable on the form, default to zero, assigning the result of the function to it (test2 = QP_DoesProfileExist(QUICKPICK_USERTABPROFILE->USERID) ), then refreshing the display of the variable.
                              There can be only one.

                              Comment

                              Working...
                              X