gianni - you make it very time consuming for people to help you.
your mysleep function looks fine to me - however my point has been made several times before - sleeping for one thousandth of a second is hardly worth doing.
so far as I can see the errors are due to missing forms and modules, can't advise any more than that - the error messages tell you what is missing.
The code looks like it has been created by someone other than yourself - either a template or from one or more forums/websites - and looks very old (access 2003 or earlier) and I suspect you have taken modules from different places and trying to combine them in some way. My point is, you need to take the time to understand what the code is doing.
I strongly advise you put Option Explicit at the top of each module (including form modules) just below Option Compare Database. Then compile your code (in the vba menu select Debug>Compile) which will highlight most of the errors you have before you need to open a form. You can make this happen automatically for new modules by going to Tools>Options on the vba menu and on the editor tab ensure the 'require variable declaration' is ticked.