There's usually something you can do to reset the modem to factory settings, either hold the on off switch for five seconds, a hole to stick a paperclip, etc.
That should clear the code.
Going forward, I tell everybody that sets a code to write it on tape and stick it to the bottom of the router. I also put the IP address and the admin password for the router.
Since you seem to have access to the router, you can just disable security and everybody will be able to access it without a password.
Of course, that may or may not be a risk depending on your situation.