Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey i have created an input box and every time i add an apostrophe symbol in it, the macro window pops up. How can i add an apostrophe symbol ( ' ) in an input box?
I have not assigned any trigger (OnChange or OnInput) to the variable which is storing the value of the input box
sub Cannotdecide_Rationale_SQLInsert
Const adOpenStatic = -1 ''these first two two lines have to be there when you are trying to insert into an external database
Const adLockOptimistic = -1
set Var_test = ActiveDocument.GetVariable("v_QVWB_CantDecide").getcontent
set Var_Row = ActiveDocument.GetVariable("v_ClaimID").getcontent
Set Var_Date = ActiveDocument.GetVariable("v_ModelRunDate").getcontent
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "dsn=NEWDMNZ1D;User ID=********;Password=********"
Set objRecordSet = CreateObject("ADODB.Recordset")
var = Var_test.string
dom ="'"
row=Var_Row.string
Mdate=Var_Date.string
objRecordSet.Open "UPDATE NEWDMNZ1D.ADMIN.GHCMO_LCP_RESULTS_SET SET RATIONAL_FOR_DECISION_TXT = "& dom & var & dom &_
"Where (CLM_NUM_CD= '" & row & "' and MODEL_PROCESS_DT = '" & Mdate & "')" , _
objConnection, adOpenStatic, adLockOptimistic
end sub
Change the below lines in your macro and try again. I replaced the variables with double apostrophe.
set Var_test = ActiveDocument.GetVariable("v_QVWB_CantDecide").getcontent
set Var_Row = ActiveDocument.GetVariable("v_ClaimID").getcontent
Set Var_Date = ActiveDocument.GetVariable("v_ModelRunDate").getcontent
set Var_test = Replace(ActiveDocument.GetVariable("v_QVWB_CantDecide").getcontent ,"'","''")
set Var_Row = Replace(ActiveDocument.GetVariable("v_ClaimID").getcontent ,"'","''")
Set Var_Date = Replace(ActiveDocument.GetVariable("v_ModelRunDate").getcontent ,"'","''")
hi,
i tried this but it is throwing an error since when i replace " ' " with " " ", the QlikView is reading the first two double quotes and reading the last double quote as incomplete (" " ")
Can you also tell me what happens if i have a OnChange or an OnInput trigger on the variable. Could this be a possible reason for input field not accepting a single apostrophe sign, please?
Hi Vikas,
Try this:
set Var_test = Replace(ActiveDocument.GetVariable("v_QVWB_CantDecide").getcontent ," CHR(39) "," " ")
set Var_Row = Replace(ActiveDocument.GetVariable("v_ClaimID").getcontent ," CHR(39) "," " ")
Set Var_Date = Replace(ActiveDocument.GetVariable("v_ModelRunDate").getcontent ," CHR(39) "," " ")
hi Hemanth,
I tried this out also but the " " " at the last is incomplete, and this is what which is giving error
Hi Vikas,
use single codes instead of double codes at the end
set Var_test = Replace(ActiveDocument.GetVariable("v_QVWB_CantDecide").getcontent ,' CHR(39) ',' " ')
set Var_Row = Replace(ActiveDocument.GetVariable("v_ClaimID").getcontent ,' CHR(39) ',' " ')
Set Var_Date = Replace(ActiveDocument.GetVariable("v_ModelRunDate").getcontent ,' CHR(39) ',' " ')
Regards
Hemanth
Hi Vikas, I was about to answer something similar to what Jonathan saids...
When a macro throws an error QV opens the macro editor, this is what is happening to you so it seems that the apostrophe is creating an error in a macro.
Maybe when the macro uses the variable the apostrophe is breaking the code (probably it comments the code after the apostrophe comes to the macro)
If you have an OnChange or OnInput wich launches a macro (or updates another field or variable that launches the macro) the error will be thrown as soon as you change the variable value.