A handful of blank prescription forms stolen from Blackpool Victoria Hospital were forged and illegally used to get pills.
David Brewer was caught on CCTV using the stolen forms on four occasions.
And he was caught after staff at a pharmacy on Whitegate Drive had suspicions and police arrested him at the scene.
The 31-year-old, of Furness Avenue, Blackpool appeared at Preston Crown Court, having pleaded guilty to four offences of dishonestly making a false representation, plus another of adapting an article to commit fraud.
The case arose from the theft of blank prescription forms during a burglary at a unit of Blackpool Victoria in March. Andrew Scott, prosecuting, said that on March 14 the hospital was made aware that a significant number of blank prescriptions forms were missing. As a result, a faxed memo was sent to all dispensing chemists in Blackpool, alerting them.
The same day it became apparent that the prescriptions were being dispensed at various chemist outlets. A trail was soon established.
CCTV showed that Brewer had entered a pharmacy on Devonshire Road, Blackpool on the 13th and handed in a prescription, in another name, for temazepam tablets. He was only given 28 tablets.
Staff were suspicious and asked him to return next day for the rest. Before he went back, staff received a fax about the stolen prescription forms.
When he returned the following day, Brewer was asked to write down his name and address on a post-it note. It was noticed that the handwriting appeared to be the same as that on the prescription, so the police were informed and he was arrested at the scene.
The court also heard that on March 12 he had gone to a pharmacy on Grasmere Road, Blackpool with a prescription for 60 diazepam tablets. He managed to get 28 tablets.
The court heard he also visited pharmacies on March 13 and March 14.
He had previously served a prison term for burgling a unit at Blackpool Victoria Hospital, and was released from jail last Christmas Eve.
Chris Hudson, defending, said “He has had a long standing drug habit. There was no financial benefit to him from committing these offences.”
Judge Heather Lloyd imposed a community order of 12 months supervision, with nine months drug rehabilitation.