Carprofen (Rimadyl) causing GI upset

My dog was prescribed carprofen for an injury. It worked well, but started causing GI upset. Specifically it was causing my Lab to have diarrhea and he was pooping on the floor in the middle of the night. He would whine and couldn't hold it before we could let him out. So we stopped the med (it was a 1-2 week course based on his injury). He took it for 1 week. Has anyone ever had this issue? How long did it take to get out of their system. The vet said the side effects stop when you stop the med, but we stopped this morning and here it is at 2 am and he just had an accident on the floor. It was not as loose as before, but still not "normal"