What is a P45 for?
Income tax under PAYE is worked out cumulatively across the tax year. Each payday, the employer looks at total pay and total tax so far and deducts whatever brings the running total to the right amount. When someone changes jobs, the new employer needs those running totals or the arithmetic starts from nothing, and the P45 is how they get them.
It has several parts. Part 1 goes to HMRC, which in practice happens through the employer's real-time payroll submission when the leaver is reported. Part 1A is the employee's own copy to keep. Parts 2 and 3 go to the new employer, who keeps one and sends the other to HMRC. The employee should never be asked to hand over Part 1A.
It is generated by payroll software when an employee's final pay is processed and their leaving date entered. There is no separate form to fill in; the numbers on it are simply the year-to-date figures from the payroll at the point of leaving.