Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.StringSet 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.
Hi,
try below one and check your Module Security & Local Security
Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE (Index2='2')")
Thanks & Regards
Hi,
You can try the below command, hope this will work
Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE Index2='"&2&"'")
Thanks & Regards
Hi,
No, didn't work. I get "Marco parse failed. Funtionality was lost" when i click OK.
//A.
Hi,
try below one and check your Module Security & Local Security
Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"' WHERE (Index2='2')")
Thanks & Regards
Hi,
I worked! Thank you so much!
//A.
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
Hi,
Yeah, it is possible
Set Result= ActiveDocument.DynamicUpdateCommand("UPDATE * SET Kategori='"&NewKat&"',Sort='"&vSort&"' WHERE (Index2='2')")
Thanks & Regards
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.
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 😃
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.