The Samsung Galaxy A40 is only 4 years old. (It came onto the market in April 2019). It uses a 4G connection so, obviously, switching to another 4G phone isn't going to help.
Switching to 5G might help but, if your local O2 5G transmitter is on the same mast that it's 4G one is mounted on, you could possibly still be in a poor reception area. It's also worth remembering that 5G isn't available across all of the UK yet. So, even with a 5G phone, you might still only get a 4G connection.
Your best option might be to stick with your existing phone (unless, other than network coverage, you've got a particular reason for wanting to change it) and try a different network.
To switch to Vodafone's network (but without paying Vodafone's prices), consider Asda Mobile, Lebara Mobile, TalkMobile or Voxi.
To try Three's network, take a look at SMARTY, iD Mobile, FreedomPop and Superdrug Mobile.
For EE's network, 1pMobile might be suitable.
(Asda Mobile has plenty of fans among ABers. I use it myself. SMARTY is also popular here).