How to Create Login Form with Security Type in Access Database

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone uh in this video i will show you how to create a simple login form uh you just need to use a username and password and login in your database for example just my username and password and click enter close the login form and go to your main form the first thing in order to create a login form we need the user table because we can refer to the user login name and the password from a user table we can create a table user here and we start with the user id as our auto num and use a full name as a tag and use the name this one we're gonna put the username and the login form the tank and password password visit is a take we can be the leader or the number we can use for the password and the next last one is um user type or user security type like admin or regular user okay if this one we use a look up from the user type table we can create a new one save we create a user type table use id order num and user type as a text we can the password data type here we in general tab here the input mask we have to chain to like a star let's see password format okay and build a data sheet here now that's how it look in the user table that we cannot see what they put in there now we set up the user table we've done this part before we create a login form let's go create some form like a user form or main form something okay let's create a main form first okay go back to the main form we just add a button to open the navigation form we can put admin page okay let's save this main form main menu okay now we got a five form main menu form which is open um the navigation form as an admin page now we get the couple form now we will create a login form create some you see the model now we need to add the textbook unbounce checkbox two of them um we name this label as a username and under the property sheet we just change the name of with textbox tt user name and add another tape box and rename as the password and change the label to password i'll format it okay we get the username and bow textbook and password checkbox and we need to put the code under the ok button let's view that form first we go cancel first and we go to the okay we can change the tab order this in there we can put zero one and two this you see the tab index now this one will be the number two zero starting zero the index password one okay two cancel three and save it login form now when we open the login form now is cursor will be forgot on the user name tag box because we put index as zero now we kick tab we go to password and click ok if we put it k is close the form go to design view to log in from now under that um okay button we gonna add the procedure even procedure under this ad will be called um for the login the name is take user name for for the username and let's see takes password name for a password text box and we need to update bb code under this ok button okay let's start to test if the user enter the username if it's newer here text you know our username or is blank we can put all immediate take user name equal to blank then uh we will give the user a message message box please enter a username we we put the information the title we can put a username required and then we can set forward on the username take bob set focus okay else if now if the username is enter and we need to test that if the password enter to go because we need both username and password take part name or meter text password equal then i just put an eve at the end same thing we can copy here paste in the password the title will be password is required and we are text password set forward else now if password and username enter is correct or not and now we import enter we go to the tested it is correct both password and both username or not we can use if this new the loop up we're gonna look up the id it matching with the username and password it's not matching on we can just you know say wrong password or incorrect password user id from table now we go back to this user open we have user id here we have username and password okay user id from this field and use a table where the user name right here ego we put apostrophe first in front of the quotation because the password in the username is a take or string need to put a apostrophe in the front and at the back majority take a username like inside before that um the name of the text okay and and you can put like this you know square bracket password equal same thing like may dot take password and if we have any dents okay uh we need more parentheses to here it doesn't have any id matching and that mean um it's wrong password or wrong username let's keep the message bob invalid username or password report critical raw username or password title and now we can set for cut back to their username that's the if statement inside the if statement now else it is correct and then we proceed the step to log in the form we can say just open the main form dcmd dot open form main menu form that the one we have the over here this main menu okay look like uh this is done for recording uh let's try it we close the login form first and let's try with jsmith and password123 open the login form one two three okay you see when i click enter that open the main form um but password is shown here we want to show the password here we need to format that text box as well okay let's format that text box is under the property sheet and data and see the input mesh here and put the silica password and finish and close that main form and open you can try that um jay smith if i open one two three four i click enter that is it the password doesn't match with the jsmith and you get the error message wrong username and password in my username or password which is confirm the code here a message invalid username password wrong because it's no id matching with the username and password when you open the form we need to we want to close that login form first do the cmd dot close and here close and open okay let's put one two three and now click enter now the close form and open the main menu form that means our login form is working with this code it's simple code the next step is to enhance our login form according to our user table we have to different type of the user it's the admin and the regular user and now when we log in we want um them to go open uh to different form between the admin and the user you know to do that we have to put the um assign variable user type id as an integer and now before the form close here we put this one equal to the lookup user type id table user where username equals to a dot user take user name quotation and upload to free addition and close now we get the id uh right here admin is id user type id equal to one and user is a tool from the user to use the type table here now it's when you close form before we open the main form here we want the admin to open the main menu user type id equal to one from here when it's e user type id equal to 1 or admin we want to open that main form else open form open mod form we want to open this user form here and if okay let's try it g smith just regular user123 password and click ok on that it's open the user form because jsmith is a user how about tt admin we open that teaching this um one two three and enter that the admins open the main menu that's how we um make the user open different form depend on the user type id or user type level that's how we do that another enhancement on the user form or the user type id or different type of the user on the main form on the beginning of my example that when you open the main form here you can see uh welcome and whoever the full name of the user like j smith maybe say welcome john smith over here depend on the user id or username that login let's do that okay i added unbrow form here and and name it as a take welcome now what we need to do is we need under the when it form load under only win procedure when formload what we gonna see you wanna see may you take welcome equal to welcome and then username or user okay now we will get the user as string you also equal to the lookup look up where they go back to the username table here at full name you want to look up under full name in here when the two wood in here we need to put the bracket square bracket here because it's not have speed between the field name and db user okay well how we get this we gonna look up we need to look up from the user id file from the user id equal to user id is a number or integer is just here uh id where we gonna get the id or we need some kind of id here we need to set the id or pass the id from the login form to this form now we need to go back to the login uh what we do we need to set the team user id when login and we want to save user id and pass through the another form when you open now we need to set the team user id as teamwork let's see we need to assign teamwork team user id equal to we can copy this statement here because it's similar similar function we gonna use but we just change over here we change the user id instead of user type id over here now we need to now we get the user id pass through the tv user id before we close the form okay now we come back to our main form here only when we need to update here user id equal teamwork team user id open the login form and i will log in as a tt now you say welcome to one t because the login tt the full name is a t1 t now let's change to a smith as admin you want to log in under a smith smith is admin let's open the main menu it's a welcome estimate that's how we open that form and show the full name of the user that login from the login form we just get the log in the user id from the login form from here and and then assign the full name to that by using this temla and password user id okay another enhancement on the user login form this main menu how about everybody when you log in the login form and we open this main menu and then show their name and the admin page enable photo admin and disable for the regular user we need to go back and change the login form let's change some vb code there over here there we want both admin and the user to open the main menu that mean we don't need this user type id here okay when you come close everybody will be logged in under main menu here when they open that main form the admin page see the admin page will be already enabled for the admin user what we need we can go copy here copy this time including the type id here put invented form load on the main form on the main form when the form load after this and we can put here and we delete this code theme user type id as long see we get the user type id because we want to differentiate the admin and the user and we need to modify here too and now user type id where the user id here equal to here you just copy here and now if this is admin we want me dot cmd you know admin page here will be um enable equal to two and if this regular user and we just copy here down and we'll be entered to four oh here that how we do that okay let's log in now we log in with the hallway which is um here which is for a regular user let's see we're compiling the administ disabled because it's regular user okay now if i log in with gtt is admin will come to you on and admin page enable that can open to see you know the admin page which is set up thank you for watching
Info
Channel: T Golden Eye
Views: 15,869
Rating: 4.712575 out of 5
Keywords: login form, set security, password
Id: KQJImKNH0fA
Channel Id: undefined
Length: 30min 23sec (1823 seconds)
Published: Thu Nov 26 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.