On a form that lists sales orders that are ready to have their pick sheet printed, there is a button called print pick sheet. The users highlight each of the orders they want to print then hit the button. The code behind the button is below. Database is SQL Server Sometimes perhaps 1 in every 200 times this function is used, it locks up the screen and this in turn locks up any other users who are after the sales header. (no messages just not response). Once we cancel the original users job everyone else gets released. Have not been able to recreate this.[:(][:(] Other problem is that if two users sitting side by side have the same list of orders up all unprinted, they tell me that the first user can print them, then the second user can print them again because on their form “Pick Sheet Printed” is still false. Any suggestions to improve code are most welcome. ie do I need to locktable? Refresh view prior to processing selection? etc etc [:I] - OnPush() // Mark all records that the user has selected and // set filter to these records CurrForm.SETSELECTIONFILTER(Rec); // Make sure order is released IF Rec.FIND(’-’) THEN REPEAT IF Rec.Status <> Rec.Status::Released THEN BEGIN MESSAGE(‘Order %1 needs to be released before you can print the pick sheet’,Rec.“No.”); Rec.MARK(FALSE); // Make sure pick sheet has not already been printed END ELSE BEGIN IF Rec.“Pick Sheet Printed” THEN BEGIN MESSAGE(‘Order %1 has already had a pick sheet printed’,Rec.“No.”); Rec.MARK(FALSE); // Make sure this customer gets regular pick sheets END ELSE BEGIN IF Customer.GET(Rec.“Sell-to Customer No.”) AND (Customer.“Use Bulk Pick Sheet”) THEN BEGIN MESSAGE(‘Order %1 should be printed using Print Bulk Pick Sheet’,Rec.“No.”); Rec.MARK(FALSE); END END END UNTIL Rec.NEXT=0; // Print pick sheets for marked records REPORT.RUNMODAL(50042,FALSE,FALSE,Rec); // Flag marked records as printed Rec.MODIFYALL(“Pick Sheet Printed”,TRUE); // Clear the marks Rec.CLEARMARKS; // Clear the filter that restricts the view to marked only Rec.MARKEDONLY(FALSE); CurrForm.UPDATE(FALSE); CurrForm.UPDATECONTROLS;
Please check this page: http://www.mibuso.com/forum/viewtopic.php?t=3734 It doesn’t explain the locking, but if the user doesn’t mark any rec OR marks all records it will still be in the “view” after the UNTIL. This means execute the report for it and modify the field. Could this be related to the problem? (Many are surprised about SETSELECTIONFILTER when they mark none or all :-))