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

Duplicate_record() creates "Argument is incorrect data type" error

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

    Duplicate_record() creates "Argument is incorrect data type" error

    I have a tbl.Duplicate_Record() line in a script and it generate the following error
    "Argumnet is incorrect data type"
    All I am doing is opening a form and wanting to duplicate a record. It works from the control panel menu line Record Duplicate but it will not work via scripts. What is the issue what am I doing wrong.

    Any help is appreciated.
    Thanks Peter

    #2
    Re: Duplicate_record() creates "Argument is incorrect data type" error

    Originally posted by pk9 View Post
    I have a tbl.Duplicate_Record() line in a script and it generate the following error
    "Argumnet is incorrect data type"
    All I am doing is opening a form and wanting to duplicate a record. It works from the control panel menu line Record Duplicate but it will not work via scripts. What is the issue what am I doing wrong.

    Any help is appreciated.
    Thanks Peter
    We'll need to see more of the script than just one line to tell for sure. The .duplicate_record() method is available for form and browse pointers. It is not valid for table pointers. What you probably want is what the documentation indicates....

    This script which is attached to a button on a form duplicates the current record:
    topparent.duplicate_record()
    There can be only one.

    Comment


      #3
      Re: Duplicate_record() creates "Argument is incorrect data type" error

      Stan,
      Here it is


      dim pCov01 as P
      pCov01 = form.load("Cover01")
      pCov01.Show()
      pCov01.Duplicate_Record(2)

      ui_msg_box("Note","Last order was placed by: " + pCov01.Cn_F_Refno)
      pCov01.Close()
      end

      Comment


        #4
        Re: Duplicate_record() creates "Argument is incorrect data type" error

        ui_msg_box("Note","Last order was placed by: " + pCov01.Cn_F_Refno.value)
        There can be only one.

        Comment


          #5
          Re: Duplicate_record() creates "Argument is incorrect data type" error

          Upon further testing if I add a filter
          for ex.
          Cn_F_Refno = Var->vcF_Refno

          Then I get the "Arguement ... " error
          Peter

          Comment


            #6
            Re: Duplicate_record() creates "Argument is incorrect data type" error

            Stan the error is not caused by the ui dialog but by the Duplicate_record() line.
            Peter

            Comment


              #7
              Re: Duplicate_record() creates "Argument is incorrect data type" error

              Originally posted by pk9 View Post
              Upon further testing if I add a filter
              for ex.
              Cn_F_Refno = Var->vcF_Refno

              Then I get the "Arguement ... " error
              Peter
              Cn_F_Refno is an object name. That object may or may not have various properties and methods available. When you use the table pointer methods you need a colon between the pointer and the object ( pCov01:Cn_F_Refno) and a period between the object name and the property you want to manipulate/discover.

              My earlier answer should have been...


              ui_msg_box("Note","Last order was placed by: " + pCov01:Cn_F_Refno.value)

              Cn_F_Refno = Var->vcF_Refno should be

              Cn_F_Refno.value = Var->vcF_Refno


              Check the webhelp for

              Object Value
              There can be only one.

              Comment


                #8
                Re: Duplicate_record() creates "Argument is incorrect data type" error

                Stan thanks I will "chew on" it regarding object value.

                But I think there might be other thing happening here.
                Below are 2 action scripts (code in red) that work fine without a filter.
                But once a filter (code in green) is added to the first action script then the Error occurs.

                'Open a Form or Browse layout, displaying all, or selected records in the layout.
                query.filter = "Cn_f_refno = Var->vcF_Refno"
                query.order = "recno()"
                'replace variables in the filter with their actual values
                query.filter = convert_expression(query.filter,"V")



                FIRST Action Script:

                'Open a Form or Browse layout, displaying all, or selected records in the layout.
                DIM Shared varP_Cover01 as P
                DIM layout_name as c
                layout_name = "Cover01"
                DIM tempP as p
                'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
                tempP=obj(":"+object_Name_normalize(word(layout_name,1,"@")))
                'Test if pointer is valid
                if is_object(tempP) then
                'Test if pointer refers to a form or browse
                if tempP.class() = "form" .or. tempP.class() = "browse" then
                'If so, then activate the already open window
                tempP.activate()

                else
                'Window is not already open, so open it
                varP_Cover01 = :Form.view(layout_name)
                end if
                else
                varP_Cover01 = :Form.view(layout_name)
                end if


                SECOND action script

                'Duplicate record in Form 'Cover01' at parent level.
                DIM object_name as C
                object_name = ":"+"Cover01"
                DIM varP_Object as p
                'Get a pointer to the specified object
                varP_Object = obj(object_name)
                'Check if the specified object exists
                if .not. is_object(varP_Object) then
                ui_msg_box("Error","The object '"+object_name+"' does not exist.",ui_stop_symbol)
                else
                varP_Object.duplicate_record(2)
                end if

                Comment


                  #9
                  Re: Duplicate_record() creates "Argument is incorrect data type" error

                  Now I'm confused by

                  But once a filter (code in green) is added to the first action script then the Error occurs.

                  'Open a Form or Browse layout, displaying all, or selected records in the layout.
                  query.filter = "Cn_f_refno = Var->vcF_Refno"
                  query.order = "recno()"
                  'replace variables in the filter with their actual values
                  query.filter = convert_expression(query.filter,"V")
                  The code in green does nothing other than full the dot variable query.filter. No action is evident following that assignment. Where is query.filter used?
                  There can be only one.

                  Comment


                    #10
                    Re: Duplicate_record() creates "Argument is incorrect data type" error

                    'Open a Form or Browse layout, displaying all, or selected records in the layout.
                    query.filter = "Cn_f_refno = Var->vcF_Refno"
                    query.order = "recno()"
                    'replace variables in the filter with their actual values
                    query.filter = convert_expression(query.filter,"V")
                    Where did you get that from?
                    I think you have things out of order and unncessarly duplicated.

                    In the above code, you declared a filter for a form that is yet to be opened, hence alpha has no clue what "Cn_f_refno " is.
                    Do you see what I am saying?
                    Cn_f_refno is an object on the form. The form has not been opened yet. The filter reference this object which is an unkown object to alpha at this point.

                    Comment


                      #11
                      Re: Duplicate_record() creates "Argument is incorrect data type" error

                      You need to, either:
                      run the query on the table then open the form, or
                      open the form first then run the query.

                      Comment


                        #12
                        Re: Duplicate_record() creates "Argument is incorrect data type" error

                        Sorry for the confusion.
                        Below are the two complete action scripts. The 2 scripts below as-is create the error. This is due to the filter expression (green) which is incorporated within the Open Form or Browse Layout script. If one removes the filter exp. from the action script then the duplicate_record works just fine.
                        Hope this explains it.
                        Thanks for helping.
                        Peter


                        Action script - Open Form or Browse Layout

                        'Open a Form or Browse layout, displaying all, or selected records in the layout.
                        query.filter = "Cn_f_refno = Var->vcF_Refno"
                        query.order = "recno()"
                        'replace variables in the filter with their actual values
                        query.filter = convert_expression(query.filter,"V")

                        'Open the layout_type showing just the records that satisfy the filter
                        DIM Shared varP_Cover01 as P
                        DIM layout_name as c
                        layout_name = "Cover01"
                        dim tempP as p

                        'Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
                        tempP=obj(":"+object_name_normalize(word(layout_name,1,"@")))
                        'Test if pointer is valid
                        if is_object(tempP) then
                        'Test if pointer refers to a form or browse
                        if tempP.class() = "form" .or. tempP.class() = "browse" then
                        'Apply the query to the form or browse as the Base query. (this means that
                        'the user cannot turn the query off, only add to the query)
                        tempP.BaseQueryRun(query.filter,query.order)
                        'then activate the already open window
                        tempP.activate()
                        else
                        'Window is not already open, so open it
                        varP_Cover01 = :Form.viewqueried(layout_name,query.filter, query.order )
                        end if
                        else
                        varP_Cover01 = :Form.viewqueried(layout_name,query.filter, query.order )
                        end if

                        Action script -Duplicate Record

                        'Duplicate record in Form 'Cover01' at parent level.
                        DIM object_name as C
                        object_name = ":"+"Cover01"
                        DIM varP_Object as p
                        'Get a pointer to the specified object
                        varP_Object = obj(object_name)
                        'Check if the specified object exists
                        if .not. is_object(varP_Object) then
                        ui_msg_box("Error","The object '"+object_name+"' does not exist.",ui_stop_symbol)
                        else
                        varP_Object.duplicate_record(2)
                        end if

                        Comment


                          #13
                          Re: Duplicate_record() creates "Argument is incorrect data type" error

                          I haven't read your entie script, but I could tell you this much: I have observed in the past that if you open a form and filter it then use duplicate record, it does not work correctly. I beleive there is a bug there.

                          What you might want to do which is what I did to get around this is:
                          open the form
                          filter for the desired record
                          Before duplicating the record, use "Show all"
                          then duplicate the record.

                          I never tried that with AS, but It might work that way. Just before duplicating the record in your AS, add another AS to show all.
                          Last edited by G Gabriel; 03-07-2007, 04:10 PM.

                          Comment


                            #14
                            Re: Duplicate_record() creates "Argument is incorrect data type" error

                            Gabriel,
                            Thanks I believe you are correct. I created test1.dbf and test1 form with the two action scripts and got the same error. After I remove the filter it works.
                            I submitted as a bug report.
                            Peter

                            Comment


                              #15
                              Re: Duplicate_record() creates "Argument is incorrect data type" error

                              Answer from Selwyn it's a timing issue. The filter takes longer to sort out db.
                              So to fix add the following code prior to issuing Dupl Record.

                              'Pause the script for a instant until the user interface has finished repainting.
                              xbasic_wait_for_idle()



                              Note this bug has been fixed according to Selwyin in ver 8.
                              Thanks to Selwyn and all for your input.
                              Peter

                              Comment

                              Working...
                              X