My first inclination was originally to assume that a lens error is the intermittent problem itself, but first, there are two more likely, possibilities, lack of sufficient power or the wrong memory card.
Remove the batteries, check the pins or connectors in the battery compartment, and make sure that they are positioned correctly to contact the battery. Then use a q-tip with alcohol to clean and dry them.
Next, the type and capacity of the card are very important. This older model camera is limited to SD cards of 2gb capacity or smaller. Please see the link below, Attempting to use one that is SDHC (4gb and up) will cause erratic operation and intermittent failures.
Please keep in mind that my diagnosis & solutions provided are directly dependent on the accuracy of your description of the problem. As with any "do it yourself" fixes, success is a "team effort", since I can't see or touch the camera, and relies on the customer's manual dexterity and ability to follow the instructions well. If the "do it yourself" approach doesn't work out for you and you need conventional repair, please let me know.
If you require additional information, please use the Reply to Expert Tab to contact me. Click the ratings only after our exchange is complete and you are satisfied.
If you are satisfied that my answer is accurate or has provided a reasonable alternative solution, please do not forget to rate my answer OK, Good or Excellent.