I download and create a pdf from a MySQL table and then open a form that has the PDF Viewer Supercontrol. The form is complaining that the pdf is in use when it is not. It'll present two error messages (file is in use) and then display the form with the pdf.
I thought at first it was a file open so I did a while loop but that didn't help.
The PDF Viewer Supercontrol gets the file name from a global variable that is populated prior to the file creation.
Don't understand the error as no other application has the file open but the error presents a sharing violation.
I thought at first it was a file open so I did a while loop but that didn't help.
The PDF Viewer Supercontrol gets the file name from a global variable that is populated prior to the file creation.
Don't understand the error as no other application has the file open but the error presents a sharing violation.
Code:
'Please Wait DIM GLOBAL pDlg1 as waitdialog pDlg1.Set_Title("Preparing Screen") pDlg1.Create(0,"Message") pDlg1.Set_Message("Please wait") pDlg1.Set_Bottom_Message("") 'Execute inline Xbasic code. 'Execute a query on a SQL database 'DIM a connection variable 'Get 'Value' property of 'Control_browse1:Documentid in Form 'Document_Header DIM SHARED v_documentid AS c v_documentid = parentform:Documentid.value DIM cn as SQL::Connection cn.open("::Name::DocManager") table = "docbinary" result_expression = "docbinary" filter = "PTNO = '00' AND DocumentID = '"+v_documentid+"'" 'Now, dump the contents of the ResultSet to a variable dim v_pdfbin as b v_pdfbin = sql_lookup(cn,table,filter,result_expression) result_expression = "docpdfFN" v_pdfFN = v_temp+sql_lookup(cn,table,filter,result_expression) 'Now, close the connection cn.close() file.From_blob(v_PDFFN,v_pdfbin) a5_addtempfile(v_pdffn) 'Conditional code follows. Executes only if the condition expression is True. IF a5_eval_expression("=Completed=.F.",local_variables()) THEN 'Open a Form or Browse layout, displaying all, or selected records in the layout. 'Check to see if you are running the script from within a Form dim flag_error as l flag_error = .f. if is_object(topparent.this) then p = topparent.this if eval_valid("P:CONTROL_BROWSE1:Docid.value") then DELETE Parameter1 'Set the Parameter variable to the object's .value property Parameter1 = eval("P:CONTROL_BROWSE1:Docid.value") else flag_error = .t. end if else flag_error = .t. end if if flag_error then ui_msg_box("Error","CONTROL_BROWSE1:Docid does not exist. This script cannot be run in this context.",UI_STOP_SYMBOL) end end if filter = "DOCID = [varN->parameter1]" query.filter = replace_parameters(filter,local_variables()) query.order = "" 'Open the layout_type showing just the records that satisfy the filter DIM Shared varP_ProcessScreen as P DIM layout_name as c layout_name = "ProcessScreen_Mod" 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 dim flagIsBaseFilter as l flagIsBaseQuery = .t. if flagIsBaseFilter 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) else tempP.QueryRun(query.filter,query.order) end if 'then activate the already open window tempP.activate() else 'Window is not already open, so open it varP_ProcessScreen = :Form.viewqueried(layout_name,query.filter, query.order ) end if else varP_ProcessScreen = :Form.viewqueried(layout_name,query.filter, query.order ) end if END IF 'Conditional code follows. Executes only if the condition expression is True. IF a5_eval_expression("=Completed=.T.",local_variables()) THEN 'Open a Form or Browse layout, displaying all, or selected records in the layout. 'Check to see if you are running the script from within a Form dim flag_error as l flag_error = .f. if is_object(topparent.this) then p = topparent.this if eval_valid("P:CONTROL_BROWSE1:Docid.value") then DELETE Parameter1 'Set the Parameter variable to the object's .value property Parameter1 = eval("P:CONTROL_BROWSE1:Docid.value") else flag_error = .t. end if else flag_error = .t. end if if flag_error then ui_msg_box("Error","CONTROL_BROWSE1:Docid does not exist. This script cannot be run in this context.",UI_STOP_SYMBOL) end end if filter = "DOCID = [varN->parameter1]" query.filter = replace_parameters(filter,local_variables()) query.order = "" 'Open the layout_type showing just the records that satisfy the filter DIM Shared varP_ProcessScreenLocked as P DIM layout_name as c layout_name = "ProcessScreenLocked" 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 dim flagIsBaseFilter as l flagIsBaseQuery = .t. if flagIsBaseFilter 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) else tempP.QueryRun(query.filter,query.order) end if 'then activate the already open window tempP.activate() else 'Window is not already open, so open it varP_ProcessScreenLocked = :Form.viewqueried(layout_name,query.filter, query.order ) end if else varP_ProcessScreenLocked = :Form.viewqueried(layout_name,query.filter, query.order ) end if END IF 'Finito pDlg1.Close()
Comment