Fixing the latch
If you feel that the latch has a problem you should look at the rotating latch prongs on the edge of the car door. As rule of thumb the latch should rotate downward. You should lift the handle in order to reveal the position of the latch. If the latch is out of place you should adjust it.
All you need to do is to ask someone to lift the door handle from the outside and hold it in an upward position. Using a screwdriver you should push the latch manually so that it rotates downward into the open position. You should then close the door and check if it stays shut.
If the door doesn't stay shut you should unplug the black cable from the car battery. You should also disconnect the power controls so that they aren't in your way. If you need to remove the crank's clip, you should use a hooked tool to detach it from inside the door.
You should then remove the inner trim panel. Most car models have their screws behind smaller trim bezels on the door and pull handles. You should remove the panels using a trim. You should note that you may be required to work the stick around the edge of the panel in order to dislodge the clips.
After moving the trim panel you should check the actuator rods and ensure that they are connected to the latch and lock cylinder. If the rods aren't connected you should connect them using their plastic clips and test if the door is working well.
If the actuator rods were connected you should disconnect them. You should then remove the bolts that hold the latch in place within the door. The bolts are usually on the outside of the door and require a Torx wrench in order to remove them.
After removing the bolts you should remove the latch through an access hole and install a new latch. You should secure it in place and connect it to the handle and lock cylinder using actuator rods