Instead of cough medicine, try drinking lots of fluid. Humidity. Honey if over 1 year of age.
If you can’t stop it, try to cover your mouth and nose with a tissue when you cough or sneeze. Put your used tissue in the waste basket.
If you don’t have a tissue, cough or sneeze into your upper sleeve or elbow, not your hands.