Memory Reset Procedure
WARNING: This page is about a different car, the 2007 Nissan Quest. However, it is still accessible from the selected car via links, so may be relevant.
If the battery is disconnected, or the sunroof motor harness connector is disconnected, the slide switch will become inoperable and the sunroof motor memory must be reset. To reset the sunroof motor memory from any sunroof position (full open, partially open, closed, partially vented, and vented), push and hold the sunroof tilt switch in the forward (DOWN) position until the sunroof is fully closed. After it has closed all the way, push and hold the switch forward (DOWN) position for more than 2 seconds to reestablish the motor preset position. The sunroof should now operate normally.