Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Insert into Sql table using Macro

Hi All

Need your help please.I am trying to update a Field in Qlikview table using a Variable and then i am Trying to write that variable value in a SQL table so that can use that value to populate the Table on reload: I am using below Macro. I am getting an Error message when i try to Insert Variable value into Table (Highlighted Red) [Object doesn't support this property or method: 'val2.Item' ]

This syntax works fine when i use a value without a variable but using variable throws error message:

Probably code needs a bit of tweaking val2.Item(i).Text .

Sub QV2SQL
SET Connection= GetAgentConnection()
dim uSQL
dim RegAfectados
dim importe
Dim Ibox1
RegAfectados = 0

set val=ActiveDocument.Fields("ID").GetPossibleValues
set val2 = ActiveDocument.Variables("vValue")
Ibox1=val2.GetContent.String


for i=0 to val.Count-1
Connection.Execute "INSERT INTO [dbo].[DQ_Challenges_Validated_Data] ([Pk_ID],[Feedback_ID]) VALUES ('" & val.Item(i).Text & "', '" &  val2.Item(i).Text & "')"
next

End Sub

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

From the APIGuide:

set v = ActiveDocument.Variables("Variable1")

msgbox(v.GetContent.String)

View solution in original post

1 Reply
m_woolf
Master II
Master II

From the APIGuide:

set v = ActiveDocument.Variables("Variable1")

msgbox(v.GetContent.String)