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: 
Anonymous
Not applicable

DynamicUpdateCommand Update problem

Hi,

I'm trying to use the DynamicUpdateCommand to update posts in a table. I use the following macro

sub Update

set vKat = ActiveDocument.Variables("vKategori")
NewKat = vKat.GetContent.String

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori="&NewKat&" WHERE Index2='2'")

if Result = false then

msgbox Result.ErrorMessage

end if

Later on I want to be able to switsch the "2" in the WHERE statment to a selected field. I've tried that but that doesn't work at all so i'm trying to get this right first.

Thanks in advance!

//A.

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

try below one and check your Module Security & Local Security

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE (Index2='2')")


Thanks & Regards

View solution in original post

9 Replies
Not applicable
Author

Hi,

You can try the below command, hope this will work

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE Index2='"&2&"'")


Thanks & Regards

Anonymous
Not applicable
Author

Hi,

No, didn't work. I get "Marco parse failed. Funtionality was lost" when i click OK.

//A.

Not applicable
Author

Hi,

try below one and check your Module Security & Local Security

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE (Index2='2')")


Thanks & Regards

Anonymous
Not applicable
Author

Hi,

I worked! Thank you so much!

//A.

Anonymous
Not applicable
Author

Hi again,

One more question while we're at it..

If i want to update several fields at the same time?

I tried this just now and it didn't work:

set vKat = ActiveDocument.Variables("vKategori")
NewKat = vKat.GetContent.String

set vSort = ActiveDocument.Variables("vSort")
NewSort = vSort.GetContent.String

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' Sort='"&vSort&"' WHERE (Index2='2')")

Is it possible?

Thanks!

Annika

Not applicable
Author

Hi,

Yeah, it is possible

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"',Sort='"&vSort&"' WHERE (Index2='2')")


Thanks & Regards

Anonymous
Not applicable
Author

Hi,

I've tried the comma too but i get an error message.

I copy pasted yours too but still the same error message:

"The Object doesn't support the method or the property" (translated from swedish to english)

//A.

Anonymous
Not applicable
Author

I made a workaround for now, simply just adding another statement like this:

Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE (Index2='"&SameIndex&"')")
Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Sort='"&NewSort&"' WHERE (Index2='"&SameIndex&"')")

Probably not the prettiest sollution but i works 😃

erikb
Contributor II
Contributor II

Hi,

I found this post when I tried find solution for my problem. I'm trying to use the DynamicUpdateCommand to update posts in a table too.  I would like to use "greater then" in "where" clausule of update statement:

sSQL="UPDATE tab_fs SET U2 = 2 WHERE Rok > 2005"

if I use " = " symbol, update statement work fine, but if I use ">" or "<" I get only empty error window.

I would like to know if it possible use  greater or lower in where clausule.

Thanks.