Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Input data from a button click

Hi!

Is possible input data into a qvd or excel, for example, from a button click?

I need to count how many users clicked in to a button. Maybe a action/macro?

Thanks!

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Input data from a button click

I did it using a macro. Thanks for the help.

sub logdet

dim oConn, rs, UserID, Datetime, v1, v2

'on error resume next
'err.clear

Set oConn = CreateObject("ADODB.Connection")

oConn.Open "provider=sqloledb.1;data source=server;initial catalog=db; User ID=user; Password=password"

set v1 = ActiveDocument.Variables("vUserID")
UserID = v1.GetContent.String

set  v2 = ActiveDocument.Variables("vDatetime")
Datetime = v2.GetContent.String

oConn.Execute "INSERT INTO DW.dbo.LOGDET(USUARIO, DATA_ACESSO) VALUES ('"&UserID&"', '"&Datetime&"')"

oConn.Close

'If Err.Number <> 0 Then
'
' msgbox("ERRO: " & Err.Number)
' msgbox("USERID: " & UserID)
' msgbox("DATETIME: " & Datetime)
'
'
'Else
'
' msgbox("All rows are now stored in database")'End message
'
'End if

end sub

4 Replies
psankepalli
Contributor III

Re: Input data from a button click

can you explain in detail..

satishkurra
Valued Contributor II

Re: Input data from a button click

If i understand you correctly , you want to insert/update data into qvd file using a button action.

This is not possible. You need to write a macro for doing this

satishkurra
Valued Contributor II

Re: Input data from a button click

Also check if the below link can help you ...

Loading Data into Input Boxes

Not applicable

Re: Input data from a button click

I did it using a macro. Thanks for the help.

sub logdet

dim oConn, rs, UserID, Datetime, v1, v2

'on error resume next
'err.clear

Set oConn = CreateObject("ADODB.Connection")

oConn.Open "provider=sqloledb.1;data source=server;initial catalog=db; User ID=user; Password=password"

set v1 = ActiveDocument.Variables("vUserID")
UserID = v1.GetContent.String

set  v2 = ActiveDocument.Variables("vDatetime")
Datetime = v2.GetContent.String

oConn.Execute "INSERT INTO DW.dbo.LOGDET(USUARIO, DATA_ACESSO) VALUES ('"&UserID&"', '"&Datetime&"')"

oConn.Close

'If Err.Number <> 0 Then
'
' msgbox("ERRO: " & Err.Number)
' msgbox("USERID: " & UserID)
' msgbox("DATETIME: " & Datetime)
'
'
'Else
'
' msgbox("All rows are now stored in database")'End message
'
'End if

end sub

Community Browser