Assuming you're in England, and all the usual rules apply to you, you should never be paying that amount for prescriptions.
If you get regular prescriptions, you would almost certainly save money with a prescription prepayment certificate.
BUT! Even if it's an unexpected one-off, if you're paying three or four prescription charges a PPC can still be well worth it, and you don't have to wait for your drugs.
When you pay for the prescriptions, you MUST ask the pharmacist for an FP57 or prescription charge receipt. You CANNOT go back and get it later, it HAS to be when you pay.
Then go on the NHS BSA website and buy a 3-month PPC for about £32, and MAKE SURE YOU BACKDATE IT to before the date you paid your prescription charges.
Then when your PPC comes through (I think it's all digital now), you go to a pharmacist with your PPC and your FP57 and you'll get a refund of the prescription charges you paid.
As a bonus you'll also get free prescriptions for as long as the PPC lasts.
Edit: I'm aware this is still shit, because it assumes you have the cashflow to pay out another £32 before getting the original £40 or whatever back, but it's a useful option that a lot of people don't seem to have been told about. (Personally I think pharmacists should have to hand you a leaflet with this information if your prescription charges are more than the cost of a PPC, or they should be able to sell you an immediately-valid 3-month PPC there and then instead of the charges, but obviously that would be FAR beyond the infrastructure of the NHS and would look way too much like caring about people's welfare.)
All this faff is also a prohibitive process for many people with other disadvantages, such as lack of familiarity with the system, lack of literacy or digital literacy, cognitive or other difficulties that make this kind of admin trickier, lack of time, stressful or overburdened lives, etc. etc.