Allow only the users with the access code to browse the website
create a page, and include the User Login as a block on that page. Theme as desired. You can also set this as a Front page in the system settings if you like.
alternatively, create a customised user login, whereby the password is populated as part of a custom submit function of the form. Then you would use a Code as the user name, and the password would be automatically assigned. The question is too broad to detail how this would be accomplished. Look into the forms API and building forms with customised submit functionality.
get LoginToboggan. It has a setting to redirect users to a specified page on access denied
in permission, for Anonymous Role, uncheck ALL items. This will essentially disallow anonymous user to do anything, or view any content, which should then be redirected to the login page by logintoboggan


Keep in mind that this method is prone to major security breaches by bots. They WILL randomly guess the code and gain access to the site, which is why two fields are required in standard practice (email/user, password)

EDIT FOR OP 

I solved it by a custom module. I cant answer my own question due do low reputation so accepting yours as an answer and writing a comment. I created a block, which contains a custom form. This form redirects to home page if the access code is correct and also sets TRUE on $_SESSION['access_code']. And then I created a page and embedded the block In a custom Rule, I redirect user to the access page if $_SESSION['access_code'] is not TRUE and if the user is anonymous whatever the URL it is. So user always redirected to that page, unless they have entered the code before, or a logged in user.