Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
ecolomer
Master II
Master II

Error in a macro

I have a strange behavior in a Macro that you need to do is update the fields in a table.

This is the macro:

sub OutLote

  for k = 1 to ActiveDocument.Evaluate("=getSelectedCount(Order_Id)")

    OutValue = ActiveDocument.Evaluate("=subfield(getFieldSelections(Order_Id, ';', 25), ';' ,"&k&")")

    ActiveDocument.DynamicUpdateCommand("UPDATE SEL SET Lote=Null() WHERE Order_Id="&OutValue&"")

  next

end sub

The strange behavior is that sometimes leaves the computer "hung" and do not know why it is. The same is silly but not see it.

Its aim is to update a table (SEL) with basic data are:

Order_Id, Lot and Date

In this case, you must make is to put the Lot = Null in the records selected through Order-Id.

In some cases, when multiple values ​​are selected Order_Id eg 10 values ​​(limit of 25), running, does it perfectly for 5 different, if we run without doing anything more, is doing well other 2 or 3 and so on down.

At the end is where you leave your computer "hanging"

Can you  check it?

TX

Enrique

1 Solution

Accepted Solutions
ecolomer
Master II
Master II
Author

New version ... QV

Now works ...!!

View solution in original post

12 Replies
phaneendra_kunc
Partner
Partner

have you tired with "Sleep" command to give it a  time to "commit" your update to your table?

ecolomer
Master II
Master II
Author

I don't know what you explain

Not applicable

Did you check the Database Logs?-Ram

phaneendra_kunc
Partner
Partner

sorry..I meant your app might be hanging because script is not giving enough time to respond..

there is a command to introduce time lag between your operations.. which is "GetApplication.WaitForIdle"

try below..

sub OutLote

  for k = 1 to ActiveDocument.Evaluate("=getSelectedCount(Order_Id)")

    OutValue = ActiveDocument.Evaluate("=subfield(getFieldSelections(Order_Id, ';', 25), ';' ,"&k&")")

ActiveDocument.GetApplication.WaitForIdle

    ActiveDocument.DynamicUpdateCommand("UPDATE SEL SET Lote=Null() WHERE Order_Id="&OutValue&"")

ActiveDocument.GetApplication.WaitForIdle

  next

end sub

ecolomer
Master II
Master II
Author

The table is only in memory, at the end export to excel

ecolomer
Master II
Master II
Author

P99.png

I have not noticed any changes

System are execute Macro and don't finish

rajeshvaswani77
Specialist III
Specialist III

You can put a message box and debug. Also if you go in debug mode line by line and it works, you would need a wait for idle then.

thanks,

Rajesh Vaswani

ecolomer
Master II
Master II
Author

Attached are QV an excel

marcus_sommer
MVP & Luminary
MVP & Luminary

In such cases I would log the activities from the macro in a txt-file:

set LogFile = fso.OpenTextFile("D:\XourPath\Log\MacroLog.txt", 8, true)

LogFile.Writeline str

whereat str = k & timestamp & Update-Statement ... & chr(10)

- Marcus