Elementary, Dear Data: AKA Holodeck malfunction episode 2
The Enterprise is rendezvousing with the Victory. Data finds Geordi in Engineering playing with a model sailboat and wanting to play Sherlock and Watson on the holodeck (oer!). They fizz over the contents of Holmes' home for a while. Data plays the violin and Geordi narrates with uncharacteristic skill. Then Inspector Lestrade turns up and the pair fail to keep in role for more than half a minute at a time. This is fortunate, as Data solves the mystery in less than half a minute, and Geordi storms off in disgust. He then enlists Dr Pulaski's help in explaining where they went wrong, and they decide to get the computer to make up a story which Data hasn't memorized.
The trio return to the holodeck, and Data once again solves the mystery in less than a minute. Pulaski is not convinced, so Geordi instructs the computer to produce a villain capable of defeating Data. Meanwhile on the bridge, the sensors detect a disturbance in the Force. On the Holodeck, one of the holocharacters who looks like the butler from the Nanny, suddenly has access to the Enterprise computer. Data and Geordi wander around until they hear a scream, find Pulaski's been kidnapped, and set off in pursuit.
Then Lestrade turns up and shows them to a corpse. Geordi attempts a diagnosis in the strangest accent either, then Data gives the correct diagnosis and culprit. Then they run off to find Pulaski, and Data reveals they're up against Moriarty. They promptly find Moriarty's secret hideout, and confront him, only to find he has awareness that there's a computer and hands Data a sketch. Data storms out, Geordi in tow, and instructs the computer to shut down the program. The computer refuses. They leave the holodeck and head for the bridge - Data shows the sketch Moriarty gave him, an outline of the Enterprise.
This is why computers have an off button. And range checking and so on.
Picard holds an emergency meeting, allowing the other cast members to pick up a pay check for this episode, and they establish it's all Geordi's fault. When a badly-worded command can screw things up that badly, I think they should be looking at the Starfleet Holodeck programmers. They discuss ways to disrupt the holodeck (Geordi has a brilliant idea with the drawback that it would be fatal to Pulaski. Thanks for wasting everyone's time there!) but before they can do anything, Moriarty reroutes control of the ship's guidance to the Holodeck and starts wobbling the ship..
Picard leads another team into the Holodeck to get Pulaski back, and he and Data are promptly held at knife-point by a mugger, leading them to suspect that the "mortality failsafe" is offline. Isn't that always the way? I don't think it's ever been online...
They find Moriarty who makes the ship wobble again. Data attempts to capitulate, but Moriarty insists he knows he's a hologram and wants to carry on his existence. Picard explains about energy and matter, and they start getting into a philosophical discussion on the nature of existence. Moriarty concedes he can't have existence outside the holodeck, and gives back control of the Enterprise, but Picard says he'll save Moriarty's program for a time when its possible.
Picard later finds Geordi in engineering examining the damage to his model boat from the shaking. Teh End.
Of course, the TV listings claim they were also going to play DS9 after it, and there's some sort of funniest home video things instead.