Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 
					
				
		
 ecolomer
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 
					
				
		
 ecolomer
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		 
					
				
		
 phaneendra_kunc
		
			phaneendra_kunc
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		have you tired with "Sleep" command to give it a time to "commit" your update to your table?
 
					
				
		
 ecolomer
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I don't know what you explain
 
					
				
		
Did you check the Database Logs?-Ram
 
					
				
		
 phaneendra_kunc
		
			phaneendra_kunc
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		The table is only in memory, at the end export to excel
 
					
				
		
 ecolomer
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		
I have not noticed any changes
System are execute Macro and don't finish
 
					
				
		
 rajeshvaswani77
		
			rajeshvaswani77
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
		
			ecolomer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Attached are QV an excel
 
					
				
		
 marcus_sommer
		
			marcus_sommer
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
