Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro read from Slider, insert into SQL query

Hi,

Please be gentle, I'm still new to QlikView, learning quite rapidly though!

I am trying to use a Macro to insert SQL data from a sheet, most of the data I've figured out for myself but I have no idea how to access the Slider value, which will be inserted into a SQL table. 

The code I have already (not working...) is

Sub InsertSQL

  SET Prod = ActiveDocument.Fields("Rework Name")

  SET ProdX = Prod.GetSelectedValues

  SET Name = ActiveDocument.Fields("RailCir Name")

  SET NameX = Name.GetSelectedValues

  Num = getVariable("Number")

  Dim sql,conn

  Set conn = CreateObject("ADODB.Connection")

  Conn.Open "Provider=SQLOLEDB.1;Data Source=SQL;Initial Catalog=MyDatabase","user","password"

  sql = "INSERT INTO Rework  ([Product],[Name],[Date],[Number]) VALUES ('" & ProdX(0).Text & "','" & NameX(0).Text & "','" & Num & "',GETDATE())"

  'conn.execute(sql)

  msgbox(sql)

End Sub

As you can see, I've referenced the two List Boxes and pulled the relative information out but I've no idea how to do it for the Slider.

1 Solution

Accepted Solutions
anlonghi2
Creator II
Creator II

Hi Jason,

try using

set MyVar = ActiveDocument.Variables("Number")

Num =MyVar.GetContent.String

instead of

Num = getVariable("Number") 

Let me know

Best regards

Andrea

View solution in original post

2 Replies
anlonghi2
Creator II
Creator II

Hi Jason,

try using

set MyVar = ActiveDocument.Variables("Number")

Num =MyVar.GetContent.String

instead of

Num = getVariable("Number") 

Let me know

Best regards

Andrea

Not applicable
Author

Thank you so much!  That worked perfectly, I do usually code in VBScript but QlikView has some odd ways of referencing these things.