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

Problem with releasing Query

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

    Problem with releasing Query

    I'm having a terrible time with getting a query to release or drop. I've tried several things such as qry.drop() query_detach_all() and several other things.

    Here is my code. Please note that this is a button inside a one-to-many set. Consumers is the parent. Timehours is the child. What I am trying to do is copy selected records to a temp file where they can then be printed.

    Code:
    'Date Created: 05-May-2014 09:34:50 PM
    'Last Updated: 06-May-2014 11:33:59 PM
    'Created By  : Charles Hoens
    'Updated By  : Charles Hoens
    DIM shared Servname as C=""
    DIM SHARED varC_result as C=""
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    DIM Servname_rl_def as C 
    Servname_rl_def = "kl=waivercodes,{keylist_build(\"H=.05,1:25[Waivercode],2:25[Waivername]\",''+waivername,left(''+waivercode,25),left(''+waivername,25))}{}"
    varC_result = ui_dlg_box("Service Name Selection",<<%dlg%
    {region}
    Select Service to Print:| [%@Servname_rl_def%.40,5Servname];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    if varc_result="Cancel"
    	end
    end if
    
    dim global invno as c=""
    e=table.open("Ident")
    invno=alltrim(e.invoiceno)
    e.close()
    
    'DIM SHARED invno as C
    DIM SHARED varC_result as C=""
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("Invoice Number",<<%dlg%
    {region}
    Enter Invoice Number:| [.10invno];
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    if varc_result="Cancel"
    	end
    end if
    
    DIM SHARED  msg2_result as N
    DIM SHARED  msg2_OK_Button as L 
    DIM SHARED  msg2_CANCEL_Button as L 
    msg2_OK_Button = .F.
    msg2_CANCEL_Button = .F.
    
    title_var = "Print Invoice"
    message_text_var = <<%text%
    You are about to print this invoice.  Press OK to continue, Cancel to abort.
    %text%
    msg2_result=ui_msg_box(title_var,message_text_var,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_ATTENTION_SYMBOL)
    'Test to see which button on the message box was pressed....
    SELECT
    	CASE msg2_result = UI_OK_SELECTED
    		msg2_OK_Button= .t.
    	CASE msg2_result = UI_CANCEL_SELECTED
    		msg2_CANCEL_Button= .t.
    		end
    END SELECT
    
    dim jac as c=""
    dim wac as c=""
    dim fac as c=""
    dim sac as n=0
    dim global eac as c=""
    dim global rac as c=""
    
    
    s=table.get("consumers")
    jac=s.conid
    wac=s.PROVIDER
    fac=word(s.lastfirst,2)+" "+word(s.lastfirst,1)
    
    
    'debug(1)
    r=table.open("temp_report.dbf")
    r.zap(.T.)
    
    t=table.get("timehours")
    query.filter = "conid = '" + jac + "'.and.isbilled='No'.and.servicename='" + Servname + "'"
    query.order = "edate"
    qry=t.query_create()
    
    t.fetch_first()
    while .not. t.fetch_eof()
    	sac=sac+1
    	r.enter_begin()
    	r.empno = t.empno
    	r.lastfirst=t.lastfirst
    	r.edate=t.edate
    	r.sttime1=t.sttime1
    	r.sttime2=t.sttime2
    	r.edate2=t.edate2
    	r.endtime1=t.endtime1
    	r.endtime2=t.endtime2
    	r.tothours=t.tothours
    	r.tothours2=t.tothours2
    	r.consumer=fac
    	r.conid=t.conid
    	r.servicename=t.servicename
    	r.serviceamt=t.serviceamt
    	r.waivercode=t.waivercode
    	r.totamount=t.totamount
    	r.nummiles=t.nummiles
    	r.print=t.print
    	r.sent=t.sent
    	r.provider=t.provider
    	r.outcome=t.outcome
    	r.service=t.service
    	r.ispaid=t.ispaid		
    	r.isbilled=t.isbilled
    	r.enter_end()
    	t.fetch_next()
    end while
    
    t.fetch_last()
    eac=cmonth(t.edate)
    rac=cyear(t.edate)
    
    while sac < 22
    	r.enter_begin()
    	r.conid="."
    	r.enter_end()
    	sac=sac+1
    end while
    
    
    query.filter = ""
    query.order = ""
    query.options="T"
    
    'Prompt user whether to print, or preview the layout. Set default to Print
    prompt_result = ui_get_print_or_preview("Print")
    If prompt_result = "Print" then
    	
    :Report.Print("DCF_Voucher1",query.filter,query.order)
    
    
    Else if prompt_result = "Preview" then 
    	:Report.Preview("DCF_Voucher1",query.filter,query.order)
    End if
    
    DIM SHARED  msg2_result as N
    DIM SHARED  msg2_OK_Button as L 
    DIM SHARED  msg2_CANCEL_Button as L 
    msg2_OK_Button = .F.
    msg2_CANCEL_Button = .F.
    
    title_var = "Update Invoice Number"
    message_text_var = <<%text%
    Press OK to update this invoice number. Cancel to leave it as is.
    %text%
    msg2_result=ui_msg_box(title_var,message_text_var,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_ATTENTION_SYMBOL)
    'Test to see which button on the message box was pressed....
    SELECT
    	CASE msg2_result = UI_OK_SELECTED
    		msg2_OK_Button= .t.
    		e=table.open("ident")
    		e.change_begin()
    		e.invoiceno=alltrim(str(val(invno)+1))
    		e.change_end()
    		e.close()
    	CASE msg2_result = UI_CANCEL_SELECTED
    		msg2_CANCEL_Button= .t.
    		end
    END SELECT
    t=table.get("timehours")
    query.filter=""
    query.order=""
    query.options="T"
    end
    What is happening is that once my report prints, the query on Timehours is still active and I can't release it.

    Any ideas are most appreciated.

    #2
    Re: Problem with releasing Query

    I see where you open table 'r' but I don't see that you close it after adding records.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

    Comment


      #3
      Re: Problem with releasing Query

      Finally fixed this, this morning. I moved much of the code out to a script. Doing so, made me have to open another instance of the dbf rather than using get. Now it's working fine. I didn't test it, but maybe just changing that within the code would have done the job.

      Thanks!

      Comment


        #4
        Re: Problem with releasing Query

        I switched to using the function indx= t.order() on recommendation by I believe Finnian years ago in place of query.filter, query.order, qry=t.query_create(), and have never experienced problems with a query remaining open since.
        Mike W
        __________________________
        "I rebel in at least small things to express to the world that I have not completely surrendered"

        Comment


          #5
          Re: Problem with releasing Query

          Using Tbl.order() on a set based form to filter the child does seem to work better. You only need to reset the filter to .t. When you want to release it, since Topparent.show_all() will not do it.
          Robin

          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

          Comment


            #6
            Re: Problem with releasing Query

            This probably has nothing to do with releasing the query but in the original script the query.options="T" seems to come after the query.create() command. It should come before the query.create().

            Whenever I use xbasic to build a query I ALWAYS include filter, order, and options. Otherwise you can run into trouble with some previously set filter, order, or option causing unexpected and/or inconsistent results.

            Another hint: Setting query.options = "MNT" seems to work every time. It sometimes takes a bit longer since it won't use any existing indexes (M) or a previous query (N) but whenever I've run into a problem of getting the wrong records in my query results, this has fixed it.

            Comment


              #7
              Re: Problem with releasing Query

              Just a bump. When researching this again - using tbl.order() to query a child in a set; has anyone else noticed that if you are using a user defined combo box, the script needs to be in the OnDepart event?

              Now maybe the next time I look up this thread, I will remember this point!
              Robin

              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

              Comment

              Working...
              X