Can't get nested If to work

Posted by: alexander on 8 January 2020, 12:45 pm EST

    • Post Options:
    • Link

    Posted 8 January 2020, 12:45 pm EST - Updated 30 September 2022, 8:22 am EST

    Hello. Somewhat of a novice with ActiveReports scripting. I have a nested If Statement that I just cant see to get to work… I have TextBox10 displayed on my report, and the values are the same, yet it’s still adding 1 for every Detail record. Basically, I am trying to do a DCount in scripting but based on a date parameter. The date part works, the TextBox9 is updating appropriately, but TextBox8 is still being incremented for EACH Detail, even if the currTransNum =s prevTransNum.

    
    Sub Detail_Format
    	dim prevTransNum as string
    	dim currTransNum as string
    	currTransNum = me.txtSTOStockTransferNumber.value
    	if me.txtSTODate.value < DateAdd("d", -15, Date.Today) then 
    		if currTransNum <> prevTransNum then
    			Me.TextBox8.value = Me.TextBox8.value + 1 
    			prevTransNum = currTransNum
    		End If
    		Me.TextBox9.Value = Me.TextBox9.value + Me.txtSTOQtyOpen.value
    	end if	
    	me.TextBox10.value = prevTransNum
    
    

    What am I doing wrong? Please see attachment where you can see the data… hope this makes sense

  • Posted 8 January 2020, 1:52 pm EST

    Looks like I was able to make this work by just adding a second group header/footer and then moving the update of textboxes 2 4 6 and 8 to groupfooter2 format… no need to compare current vs previous values that way.

    Would still love to know if theres a better layman’s way of making this work.

  • Posted 9 January 2020, 10:16 pm EST

    Hello Alexander,

    I am glad that you found the solution yourself. However, as per your description, textbox10 is incremented by 1 but I can’t find the same in the image. Could you please share the report with dummy data so that I can look into this.

    Thanks,

    Mohit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels