Problem with LCD and Motor

I'm having the same symptoms when using a 5v relay to switch current from a 12v supply to a solenoid. I put a 2n4004 diode across the coils of the relay and the solenoid to short the back EMF, but no joy. It works OK with just the relay clicking on and off, but one or two cycles of the 12v solenoid takes out the LCD. Should I try the capacitor across either or both DC supplies?