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.
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.
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
Any ideas are most appreciated.
Comment