Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Olá Pessoal,
Alguém ai sabe me dizer como é que altero o valor de um campo (Field) por macro no QlikView?
Para altera uma variável é assim:
ActiveDocument.GetVariable("NomeDaVariável").setContent "Valor",false
E para alterar um Field de uma tabela que foi carregada no QlikView, como faz?
Para ler o valor faz assim:
ActiveDocument.Fields("NomeDoCampo").GetPossibleValues.Item(0).text
Tentei fazer como abaixo, mas não dá erro e não funciona, alguem sabe dizer como fazer?
ActiveDocument.Fields("NomeDoCampo").GetPossibleValues.Item(0).text = "abc"
Grato pela atenção de todos, abraço.
Olá Aderlan,
Você de utilizar as funções de dynamic update.
Segue exemplos retirado do arquivo QlikView APIGuide.qvw.
Rem Dynamic Data Update
sub Update
SET Result = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Discount = if(Discount >= 35, 0, if (City='Stockholm', Discount + 5, Discount + 2)) WHERE Country = 'SE'")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
sub Insert
SET Result = ActiveDocument.DynamicUpdateCommand ("INSERT INTO * (Country, City) VALUES (DK, Copenhagen), (NO, Oslo)")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
sub Delete
SET Result = ActiveDocument.DynamicUpdateCommand ("DELETE FROM CITY WHERE IsNull (Discount)")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
Abraços.
Tonial.
Olá Aderlan,
Você de utilizar as funções de dynamic update.
Segue exemplos retirado do arquivo QlikView APIGuide.qvw.
Rem Dynamic Data Update
sub Update
SET Result = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Discount = if(Discount >= 35, 0, if (City='Stockholm', Discount + 5, Discount + 2)) WHERE Country = 'SE'")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
sub Insert
SET Result = ActiveDocument.DynamicUpdateCommand ("INSERT INTO * (Country, City) VALUES (DK, Copenhagen), (NO, Oslo)")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
sub Delete
SET Result = ActiveDocument.DynamicUpdateCommand ("DELETE FROM CITY WHERE IsNull (Discount)")
if Result = false then
MsgBox Result.ErrorMessage
end if
end sub
Abraços.
Tonial.
Obrigado Tonial,
Quando eu tiver mais um tempo foi tentar, por hora, estou trabalhando em outros projetos.
Valeu, abraço.