# Database Discussions > Microsoft Access >  How to create user login form (MS Access 2000 - 2003)

## meLady

*Hello,*

I have a table called "users", it has two fields "username" and "password".

I have a form called "User Login Form".  It has two text boxes and a button as following:

1-  txtUsername
2-  txtPassword
3-  btnEnter

I would like to link these textboxes with a table.  The idea is that the user must enter his/her username & password in the mentioned text boxes.  Then, the user will press the enter button.

So the system will varify the input, if it not correct the error message will appear.  If it correct, then the required form will be displayed (^_^).

this process is very new for me and I would like to learn it and I would be more appreciate with your kindly assistance.

----------


## Allan Murphy

I have developed a similar Login form that validates the User ID and Password plus it also validates the users password expiry date. If you like I could send a sample to you or post it to this group.

I use a form with unbound boxes for the Userid and Password, when the user presses the Button to access the database I use a couple of Dlookups to check for a valid user then check for valid password. If both are correct then the next form is opened. If either is incorrect then a message is displayed, the user then has the option to re-enter the user id and password or click on the Exit button to close the database

----------


## josef

Hey bro.
Are you still in need of a code to sort this out?
we can work it out.
Even you are able to disable and account after a x number of unsuccessful attempts.

----------


## Jrenter2

I too am looking for an example of the above mentioned problem if someone could please post one or email me that would be greatly appreciated.

thank you in advance!  :Smilie:

----------


## meLady

Hello,

It is very pleasure to see you giving me a help, well to be honest the login process is the first problem that I have and I need some explanations with codes in order to learn and understand it carefully, if you don't mind.

It will be very pleasure to have your help (^_^)

I am waiting for your reply as soon as possible.

----------


## Allan Murphy

If you require a copy of my demo version of the login screen
please send me an email at *allanmurphy@unwired.com.au* as the size of the file exceeds the attachment limit

Allan

----------


## meLady

Hello Allan,

My email address will be *only-me-puppeteer@hotmail.com*  I will send you a message  :Big Grin:  

See you there then  :Cool:   bro

----------


## cyber-guy

I too am looking for a similar solution with one slight difference.  Once a person is logged in, I want the app to load a predetermined form for that person - in other words, bob logs in and gets the warehouse form, Shirley logs in and gets the accounting form, etc.

Thanks in advance,
Cyber-guy

----------


## cyber-guy

Here's a login script that looks like it might work quite nicely - it works on Access 2000, I haven't tried it on 2003 yet - the attached file has the .mdb sample along with the passwords to test it with.

It uses a dropdown for the user name.  Passwords are masked with *'s and it kicks you out after 3 failed attempts.

You can get more info at http://www.tutorialized.com/tutorial...utorials/10952

Cyber-Guy

----------


## Allan Murphy

Here is my sample login screen database.

Open frm_main use either TEST1, TEST2 OR TEST3, the user ID determines the level of access. Whne you first login you will asked to change the password as the password has expired. This is a feature that I use as a bit of security etc.

Contact me if require more information etc.

Allan Murphy
allanmurphy@unwired.com.au

----------


## cyber-guy

Very nice!

Thanks,
Cyber-guy

----------


## Allan Murphy

Thank you, I hope it suits your needs.

Let me know if require any more information etc.

Allan

----------


## meLady

*Hello Allan,*

How are you?  Thanks for the login demo, actually I have been studying the coding and trying to understand the procedures of your login screen.. your login screen has provided me lots of understanding like the way of building the forms and the way of coding using the VB ... Thanks for your help and I will try to understand it more by having more and extensive exercises in creating the login screen and compare it with yours.  :Big Grin:  

Again Thanks A lot  :Cool:   friend  :Smilie:

----------


## Allan Murphy

Thank you for your comments.

If you like I will post on the forum a more detailed explanation of the Login Screen concept with some  explanation of the coding etc.

Regards

Allan

----------


## z3ronim

hye...i already try just like above...but i want try more advance...i want add and edit function for new user and existing user...can anyone help me?

----------


## Allan Murphy

If you Login into my sample as TEST3 you will see a menu item title Add/Edit Users it is a continuous form.

Would you prefer a form to Add and another form to Edit an user? Please provide your requirements.

Allan

----------


## z3ronim

im sorry allan,but i dont know where to find TEST3..maybe you can provide another to me,it will be my pleasure =)


edit by admin: no contact info permitted on the forum, thank you

----------


## wowz316

> I have developed a similar Login form that validates the User ID and Password plus it also validates the users password expiry date. If you like I could send a sample to you or post it to this group.
> 
> I use a form with unbound boxes for the Userid and Password, when the user presses the Button to access the database I use a couple of Dlookups to check for a valid user then check for valid password. If both are correct then the next form is opened. If either is incorrect then a message is displayed, the user then has the option to re-enter the user id and password or click on the Exit button to close the database


Hi Allan,

I was wondering if you still have this login form available. I'm kinda new to databases and was wondering how to use a similar login for an existing database. At the same time do you know how to change the first window/form that appears when opening a database? 

Thanks!!

----------


## Allan Murphy

The sample database is an attachment to one of my replies on the page 1 of this thread.

What do you mean *how to change the first window/form that appears when opening a database?* 

You can set a form to be displayed when the database opens by going to the menu bar select Tools, then select Startup from the dropdown menu, a dialog box is displayed, then in the Display Form/Page, select the form you want to display when the database opens.

----------


## Ronald

Good day!

Can you please send me a copy of Log-in form in Microsoft Access? I also want to use such kind of form instead of using workgroup security. 

Thank you in advanced...
Hope to hear from you...

Thanks once again...

Ronald

----------


## Allan Murphy

Ronald

The sample database is an attachment to one of my replies towards the bottom of page 1 of this thread.

----------


## nubian_p

Hi Allan, Im have created a database and need to apply the security settings 3 levels as you have done to show certain buttons for the 3 levels. I Have looked at your code and still can seem to understand what you have done. Can you please help!!!!!!!

----------


## Allan Murphy

I am not using the Security Level settings available in Access.

I have a table tbl_users that has the user's details, the field *access_level* is a term that I use to determine the menu items (switchboard) that will be displayed when the user logs in.

Briefly this is how it works.


 - User Logs in with an User Id and Password.
 - User clicks on ENTER
 - Module display_menu in mod_display_menu is called
 - variable valid_user is initially set to 2 as a flag inidcate a valid user.
 - Variable check_user is check if the user_id exists in tbl_users.
 - If it is a valid user then the user's password at login is checked against the password in tbl_users.
- if the user id and password are correct then the user's access level is obtained. This access_level will be used to displayed the relevant menu (switchboard).
- The Select Case valid_user. Case 0,1 are for invalid user id or password. Case 2 is for a valid user.
 - The Select Case access_level is used to display the relevant menu. The variable password_period is used to check the expiry date of the password. If the password has expired then the user is FORCED to change their password by opening the form frm_change_password. If the password has not expired then the switchboard is displayed relevant to the access level. If for some reason there is an invalid access_level a message is displayed to the user.
 - When the form frm_change_password is displayed the user must change their password, the password expiry date is set to the current date plus 30 days. Then the relevant menu is displayed using similar code for the access_level in the above Select Case access_level in the form frm_change_password.

Contact me if you still need more information.

----------


## GGXX

Hi Guy,

I downloaded the attached file. But, it did not work with the password you provided with the txt file.
Also, I CANNOT open any OLD db file from now. Access need to input login and password every time.

How come? :EEK!:

----------


## loganathan

Hi

I am Logan.  I need the form design and coding for the first time as sample.  Thanks & Regards.

Loganathan.R




> I have developed a similar Login form that validates the User ID and Password plus it also validates the users password expiry date. If you like I could send a sample to you or post it to this group.
> 
> I use a form with unbound boxes for the Userid and Password, when the user presses the Button to access the database I use a couple of Dlookups to check for a valid user then check for valid password. If both are correct then the next form is opened. If either is incorrect then a message is displayed, the user then has the option to re-enter the user id and password or click on the Exit button to close the database

----------


## Allan Murphy

Look at message 10 on this thread

----------


## cutebj

I will appareciate your help on how to create a user  login form which i can link with a  database table,using MS Access 2003.

Thanks,
cutebj.

----------


## Allan Murphy

Message 10 on this thread will give you some ideas. Otherwise post your requirements.

----------


## Engr. Clement

[QUOTE=meLady]*Hello,*

I have a table called "users", it has four fields "username", "password", "Login Time" and "Log out time"

I have a form called "User Login Form".  It has two text boxes and a button as following:

1-  txtUsername
2-  txtPassword
3-  btnClick

I would like to link these textboxes with a table.  The idea is that the user must enter his/her username & password in the mentioned text boxes.  Then, the user will press the enter button.

So the system will varify the input, if it is not correct the error message will appear.  If it correct, then the required form will be displayed.
What do I do?
I would be glad if any body can help with with this.
Thank U.

----------


## Allan Murphy

Please read through the thread and if you still require more information please post your question to the forum I will assist you.

----------


## angel_001

Hi,

Thanks for your sample database.

After Logging in to the database, I would like to add a new form that can add a user.

I have 4 textboxes

1. Name
2  Email Address
3. UserID
4. Password

I also have a command button, Add user

The textboxes should all be clear at first. Then after filling up the textboxes and when I hit the Add user button, The profile should be saved in the database and then all the textboxes should be cleared. 

Thanks for your time.. :Smilie:

----------


## Longship

Good afternoon,
I have used your login form and it is quite useful and easy to adapt to my needs.  I have several processes that run and I would like to stamp them with the user_id that initiates them.  I have tried to work with the user_id from the main login screen but have not been successful.

I have limited VBA experience and I was wondering if there is an easy way to 'store' the user_id data for use later?

Thank you.

----------


## Allan Murphy

Longship and angel_001

I have combined your messages into the attached updated sample.

*Longship*
I have added a form called frm_utility to store the user's login id. This form is opened after a valid user has logged in e.g a valid login user id and password. This form is hidden when opened. The module mod_display_menu has been modified as shown in BOLD
Select Case valid_user

    Case 0, 1
            strmsg = " Access Denied" & _
                        vbCrLf & " Contact your Administrator if the problem persists.   "
            MsgBox strmsg, vbInformation, "INVALID USER ID or PASSWORD"


    Case 2
* ' open and hide the utility form frm_utility
            ' this form will be used to store the user id for as as required e.g recording the user id of an
            ' user adding records etc.
            DoCmd.OpenForm "frm_utility", , , , , acHidden

            'store the user id on the utility form frm_utility
            Forms!frm_utility!user_id = Forms!frm_main!user_id*

When you want to stamp a process with the user's id you would something like this user_id=forms!frm_utility!user_id

*angel_001*

Log in as TEST1 with a password TEST1 you will see two menu items for adding a new user, the first menu item will display the users using a continuous form, I use this method at work. The second menu is a per your message in that it will open a blank form called frm_add_user_form, the user enters the data then clicks on the Add New User button. Clicking on the Add new user will add the screen data to the users' table tbl_users, after the data is added to the table the screen is cleared ready for another user entry. When you click on Close and Exit the form closes without saving the data entered on the screen.

----------


## Longship

I was trying to put the code within each of the access levels and it wasn't working.  I already had a form to house the user name so it was just a minor name change.

I appreciate all of your help.  This has been an invaluable solution and it is helping me further understand VBA (a little).

Thanks again.

----------


## benne143

hi allan
i have read all the threads concerning user login and downloaded your samples.  thanks for the samples.  I was wondering if the user login can also apply to the mysql user accounts.  I use Access 2003 as a front end and the actual database is made and stored in mysql.  The ODBC connections work great my forms and tables and querys work great i just want to set up a user login on the front end sign using the users that were set up in mysql with what ever rights i gave to them there.  After i do that i can handle all the other things on the thread here because u have everything so well written.  Just need help connecting the user login to the mysql user accounts.,  your help would be greatly appreciated.. thanks.

ben

----------


## Allan Murphy

Ben

Thank you for compliments.

I do not know how this will work with your mysql user accounts as I have no knowledge of mysql. Basically, when a user logs in their access level is checked and the relevant menu is opened. The only way to find out is to "give it a go".

Regards

Allan

----------


## Yam716

Hi Allan,

Thank you for posting your login utility.  I am trying to adapt it to my own program however I am not able to go into design view. How were you able to make it so that the users can not change the view type? This will be useful to me in designing my own programs. 

Thank you for you assistance.

----------


## Allan Murphy

What do you mean by " *How were you able to make it so that the users can not change the view type?* "   On startup the Login form is displayed and the user does not see the forms, tables etc.

I have attached a demo version that will not display the Login form on startup. Please contact me if you require more information.

----------


## Yam716

Allan,

Thank you for your response.  I meant that I could not put the form in form view to view the code.  I can accomplish that with the new one you attached, but I would like to make it so my users can not go in to design view, so I wanted to know how you did that.

I sent an email to your email listed in this thread earlier today. I am trying to design a login and password for my users so that i will know who is logged in, should I need to make changes, I need to know who to tell to close the DB so that I may make my changes.

I am having trouble figuring out how your buttons work and making my own based off the logic.

This part:
    'Constants for the commands that can be executed.
    Const conCmdGotoSwitchboard = 1
    Const conCmdOpenFormAdd = 2
    Const conCmdOpenFormBrowse = 3
    Const conCmdOpenReport = 4
    Const conCmdCustomizeSwitchboard = 5
    Const conCmdExitApplication = 6
    Const conCmdRunMacro = 7
    Const conCmdRunCode = 8
    Const conCmdOpenPage = 9
I did not understand, but after lookin at it for a while I came up with something.

After successfully logging in, a form comes up with the options available to a user with a certain level of access granted to them.  I try to see the code behind that form and I am having trouble trying to understand it.
I have modeled my switchboard tables after yours. I have deduced that:
-Each table represents, given the user level of access, the items the user would see on the switchboard.
-ItemNumber represents the button number (ex.  HandleButtonClick(4)) which refers to the 4th button on the form?
-ItemText represents what the button does (ex. Add New User)
-Command represents the action taken when the button is pressed 
(Const conCmdGotoSwitchboard = 1
    Const conCmdOpenFormAdd = 2
    Const conCmdOpenFormBrowse = 3
    Const conCmdOpenReport = 4
    Const conCmdCustomizeSwitchboard = 5
    Const conCmdExitApplication = 6
    Const conCmdRunMacro = 7
    Const conCmdRunCode = 8
    Const conCmdOpenPage = 9)
-Argument represents macro or form to be opened if the command is taken
-SwitchboardID represents ?--I am not sure.

I thought I figured it out, but then I signed in to see if each screen would be different based on the user and their access level;everyone had the same switchboard after signing in.

I am trying to understand your model so that I can make my own, please explain the above mentioned items.  Thank you

----------


## Yam716

Hi Allan,

I have made some progress since I wrote my inquiry yesterday.

I have found information regarding my questions I asked in my earlier post.  I am still having trouble though.  I used your demo to make my own version to work with my system.  I have a question about the switchboard levels.  I understand that each switchboard table represents a diff level of access.  I have 3 tables.  My question is concerning the tables' first entry:
SwitchboardID: 1, ItemNumber: 0, ItemText: Main Menu, Command: 0
After loggining into my system (trying to access level1), I am prompted to enter the ItemNumber.  
When trying to log in as user 3, after entering the username and password, I get a message that says this method is not supported.  Can you tell me how to step through the issue to determine where the error is?

----------


## Allan Murphy

I have not seen that prompt to enter the ItemNumber.

Would you please upload a copy and I will have a look at the problem

----------


## Allan Murphy

Yam716

This prompt for ItemNumber is displayed because the field named ItemNumber could not be found in the relevant switchboard table.

If you changed the name of the fields in your switchboard tables then you will need to change the coding behind the switchboard forms or rename the field that was originally named ItemNumber back to the original name ItemNumber or you could also change the coding.

----------


## boanet

Allan,

I like it a lot, only problem is that when i tried the demo i only got level one menu regardless of who i loged in as, any idea why? it always gave me switchboard_lev1.

----------


## Allan Murphy

boanet

It was my mistake, when I made copies of the switchboard_lev1 for the other switchboards I did not change the record source and some minor coding on the new switchboards.

Attached is an updated version. Please contact me if require assistance etc.

17/11
Sorry, All I forgot to upload the zip file.

----------


## pctaz

Allan, I like your demo file and am trying to incorporate it into something I am working on. 

I created another table with some record info, the last two columns being an ModifiedDate and Modifiedby.

I then created a form to enter the records and set a before update event to record the time the record was modified, what I can't get is it to record the modified by, it asks me for the user id. Since I logged in when the db starts I thought I could pass the variable but it doesn't seem to be working. any ideas?

thanks

----------


## Allan Murphy

In the module mod_display_menu  

Select Case valid_user

Case 2
' open and hide the utility form frm_utility
            ' this form will be used to store the user id for  as required e.g recording the user id of an user adding records etc.
            DoCmd.OpenForm "frm_utility", , , , , acHidden

This code opens a form frm_utility and hides it. When the menu screen opens the Login screen closes.

To store the user id you need to do the following

me!user_id =forms!frm_utility!user_id

change me!user_id to your variable name etc.

Message #44 has the latest version with the frm_utility

----------


## pctaz

ok, so I'm a dufus, I saw the lines you were talking about (after I downloaded v3) I looked at the utility and it shows the user I logged in as. I tried the modified line in my event proceedure but it wouldn't let me save the record or anything. I had to take the line back out. 
(i zipped it but it's like 108k so it wouldnt attach)

----------


## pctaz

i played around with it and still haven't firgured out where I need to put the line to fix it.

i put compressed it with rar, then put it in a zip so I could attach it


thanks again!

----------


## Allan Murphy

In your code for form Table2 you can not have Me!user_id = Forms!frm_utility!user_id outside the Sub and End Sub

Change the code in your form Table2 to read as below.

Option Compare Database

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![ModifiedDate].Value = Now()
Me![ModifiedBy].Value = *Forms!frm_utility!user_id*
End Sub

----------


## pctaz

yeah I tried that first, I kept getting error:
The expression Before Update you entered as the event property setting produced the following error: Invalid Outside proceedure

I figured I did something wrong and tried different ways in different places.

----------


## Allan Murphy

By having the code outside the SUB you will get that error message.

I have attached an updated version with the correct code. The User Name and Password is FRED. I have placed a menu item to open the form Table2. Try it and let me know if there are any problems.

----------


## pctaz

i don't see an attachment, did you update the one in post 44?

----------


## Allan Murphy

Sorry, I did not realise that the attachement was over the limit before I sent it. 

Please send your email address to my email address below and I will send you the zip file. Alternatively I will add the form Table2 as a zip file to this thread.

----------


## pctaz

email sent

----------


## pctaz

Allan,
I am still playing with this. I was trying to test the login after I have made some other forms and changed the switchboard to those forms. Now I get the login prompt, when I login the switchboard flashes and then goes away. I also tried the password change form, I can change the password but the exit doesnt work it will never exit the form.
I can't see anything wrong, I didn't change any of that code.

thanks

----------


## Allan Murphy

Please post a zip copy of your database and I will look at it.

----------


## pctaz

too big, will email it.

----------


## mrs_everything

Hi Allan, 

I'm a student, and I am attempting a project in Microsoft Access 2000. I have to create a user login form. I must use the username and passwords from a table and accordingly either allow access to the main menu or deny access. However, I am supposed to do this using macros. How can i do this? 

I have a few more problems i encountered while doing this project, such as displaying an error message when the incorrect info is typed in, or clearing the text box after it is used. 

i am very new at this, i hope you can help me! sorry for all the trouble and thank you very much! 

Sarah

----------


## skumar.smsit

> *Hello,*
> 
> I have a table called "users", it has two fields "username" and "password".
> 
> I have a form called "User Login Form".  It has two text boxes and a button as following:
> 
> 1-  txtUsername
> 2-  txtPassword
> 3-  btnEnter
> ...


but how to link user name text field to table text fied

----------


## Allan Murphy

Read the messages and at message 45 is a demo version. Please contact me if you require more information.

----------


## mayy anis

> *Hello,*
> mayy anis
> I have a table called "users", it has two fields "username" and "password".
> 
> I have a form called "User Login Form".  It has two text boxes and a button as following:
> 
> 1-  txtUsername
> 2-  txtPassword
> 3-  btnEnter
> ...


i have the same proplem so please give me the solution

----------


## Allan Murphy

Please read through this thread as I have placed examples in various messages.If you still require more information please post to this thread

----------


## mayy anis

thanks a lot

----------


## brslo07

Hi allan,

Very nice login function you have posted. I have some questions. First, when you are logged in, and you want to have a list on the main menu, showing who is logged in, how can I make this? And second, I have made my own login function, but it is only one of the passwords which are working. Why? Is it my programming or something?

Rg. Brian

----------


## Allan Murphy

Hello Brian

Thank you for your comments.

To see who is logged in try this site: http://support.microsoft.com/kb/198755

What error message is displayed? Post your database to the forum, remove any confidental data before posting, just use sample data.

----------


## yuan

Thank you, I hope it suits your needs.

Let me know if require any more information 




tiffany earrings
tiffany pendants
cheap tiffany rings

----------


## tariqgohar

> If you require a copy of my demo version of the login screen
> please send me an email at *allanmurphy@unwired.com.au* as the size of the file exceeds the attachment limit
> 
> Allan


hello there! i need help about above topic How to create user login form (MS Access 2000 - 2003) 
please help me
my email add is *tariqaligohar@gmail.com*
thanks in advance.

----------


## JoshR

Hi Allan, 

Thanks for all the demos you've provided. I'm fairly new to Access and your demos have been a great start in helping me remember my VB and learn Access' tools. 

I have a quick question, in of the files you uploaded (login_demo_3.mdb) you were able to make 3 levels of security. I don't see how this is secure as when I log in with Level 1 access, I can still just go to the side panel, click on tbl_users and edit the users. 
Is there anyway of making a database so that level 1 can only add information to given tables and create reports of them, but cannot edit in anyway, while level 2 has unrestricted access?

Your quick reply is greatly appreciated. 

Thanks, 
Josh

----------


## Allan Murphy

Josh

This databse was to show members how to mutliple access levels without using the security levels that comes with access.

You do not give the user access to a table so that they can   add, edit or delete a record. You must use a form as an interface.

If you look at switchboard_lev1 in the ItemText field there is a menu item *Add new User - Continuous Form* in the command field there is a 2. When the user selects this menu item the code in the *Private Function HandleButtonClick(intBtn As Integer)*  opens the form that is in the argument field for that menu item in the ADD mode only.

The next record in the table has a 3 in the argument field this allows  the user to Edit a record.

To prevent the user seeingg "behind the scenes you will need to set your Startup options. What version of access are you using?

Reply to me off list and I will try and assist you.

----------


## treypack

This is the best login screen that I have yet to demo.

Thanks Alan

----------


## Allan Murphy

If I have time over the next couple of weeks I will post a variation to my previous examples. This new one does not access levels where there is a different switchboard for each level but one where the menu items are populated depending on the user's role.

----------


## Cygnus111

I just want to say Allan Murphy is a GOD.  I was looking for something on Google, ended up here, already knew how to do this but after reading the posts realized he has carried this topic for FOR DAMN YEARS!  That deserves a medal, dude.  Cheers to you, mate, and the few with your patience and perseverence.

And YES, I did register on this board for the sole purpose of making this post.  You rarely see generosity like this, so when you do you have to give props.

----------


## dowams

Hey Allan, really appreciate your working sample on this ms access program. was searching for some reference to do my latest project and found your site on google. Am bookmarking this topic and followups. Please share further on any samples and it will be greatly appreciated.

Thank you!

----------


## stewartsetter

Hi Allan, 

Your Demo is fantastic, how do i change the button headings as it keeps defaulting back to the original.

thanks, 
Stewart

----------


## Allan Murphy

Hello Stewart

The attached document explains the switchboard table. You ItemText to chnage the menu item.

Also read my reply on 06-08-2011 03:44 PM message 69 from memory that explains what the action means.

Please contact me if require further assistance.

----------


## Nando

Hi Allan,
I don't know if it0s ok to ask you this here but since its the same topic

I'd like to know how can I implement a login form in access 2010 for a web database meaning that I can't use VBA and it only has to implemented with macros.

Right now I have a table called users and I can verify if the user existsin the table to open the main form BUT I have the problem where the user just can close the window of the login form and they will be taken to the main form  :Frown: 
How do you get to block this only with macros? I think there's not an onUnload event handler  :Frown: 

Thanks!

----------


## Allan Murphy

Sorry, I do not experience with web databases. 

Just a thought, on your Login form you could set the following properties Close Button from Yes to No. The Min Max buttons from Both Enabled to None. I know in an ordinary database this prevents the user from Closing the form or Minimising or maximizing the form.

If this fails may I suggest you post your request to the forum.

----------


## Nando

Thanks Allan for your reply.

Well, unfortunately it seems that on web databases the forms don't have all the functionality available  :Frown: 
Close button and min max buttons properties are not present so I'm not able to control that way.

I'll just have to think a way to disable everything in the main form if some temp var has not been initialized. This way the user could close the login window but will end up with a main form completely disabled.

----------


## niso

> I have developed a similar Login form that validates the User ID and Password plus it also validates the users password expiry date. If you like I could send a sample to you or post it to this group.
> 
> I use a form with unbound boxes for the Userid and Password, when the user presses the Button to access the database I use a couple of Dlookups to check for a valid user then check for valid password. If both are correct then the next form is opened. If either is incorrect then a message is displayed, the user then has the option to re-enter the user id and password or click on the Exit button to close the database



Can you please forward me the as I would like to see how this code works

----------


## Allan Murphy

Niso

I you have a look at message 43 or 44 on this forum you will see examples of my login screen etc. The validation code maybe on the login screen or a module called Display menu.

----------


## niso

Thanks Allan, I hope its gonna work but I will let you know if I had any problems.

----------


## m@rk

Hi Allan,
     Thanks  for this Login example, its just what I was looking for!
Just a quick question, I am wanting to display the logged in user name on a form so it acts as a signiture, how do I display this.

  Once again thanks,
      m@rk

----------


## Allan Murphy

Hello m@rk

That you for your comments.

By forms do you mean the screen or a form printed as a report.

About message 43 on this forum gives details regarding displaying and using the user id. Here is a snippet from that message




> 'store the user id on the utility form frm_utility
> Forms!frm_utility!user_id = Forms!frm_main!user_id
> 
> When you want to stamp a process with the user's id you woulduse  something like this user_id=forms!frm_utility!user_id


The frm_utility is open and hidden when the user logs in, the user id is stored on the form. So to use it on the screen or in a report you make reference to the user id as above

----------


## m@rk

Hi Allan, 

  Thanks for your reply, I hav tried making a reference to the user id (by copying the text box) from the frm_utility but it still doesnt seem to work?

I basically want to display the name of the person logged in and then populate a form field as a sort of digital signature. (currently the task is done on paper and then signed off)

Can you offer any further help / example on doing this?

   Thanks,
       Mark.

----------


## Allan Murphy

Hello Mark

On your form or report add a text box and set the record source to =forms!frm_utility!user_id

Regards

----------


## kan

Hi Allan,

I am so newbie one. I also need your login that don't need level.

Please kindly help to forward to me on kanporn@hotmail.com

Thanks in advance

----------


## Allan Murphy

Have a look at message 44 on this thread. Do not use the code that determines the access level.

The login validates the user ID and password, check sfor expiry date of the password. Then opens a switchboard depending on the user's access level.

If you have problems with the please post your attempt to this thread.

----------


## sherryb41

Allan, I have tried to follow other's examples of login screens and always something was left out or not explained. I really appreciate you helping us here. I have downloaded the example in #10 and opened it in Access 2003 and it works just fine. When I import it into Acess 2010, it stops with the error message: Object doesn't support this property or method. Can you tell me what I need to change to make it work. Thanks.

----------


## Allan Murphy

Sherry

Thank you for your comments. This is my way of thanking other people who posted various solutions that helped me over the years.

Your problem maybe due to not having a reference set in Access 2010. At the moment I am using Access 2007 not Access 2010.

I have attached a screen shot of the references required for Access 2007 there maybe similar references for 2010. I have also included a zip copy of a newer version of the #10 this new version is located at #43 from memory. I may have made some minor changes to this version.

When I install Access 2010 I will update this thread.

----------


## Allan Murphy

Sherry and all previous viewers

Here is the login version in Acccess 2010 format.

----------


## cathrine

Yes I would like a copy of your login demo. I am having trouble creating one. 
email me at meds22cathy.co.uk.
Thanks Cathrine.

----------


## Allan Murphy

Cathrine

Have a look at message 44 on this thread.

----------


## Allan Murphy

Cathrine
Your email address is invalid.

----------


## Iraqismoker

I have a question I have this login form which is really good but I want to add a Dlookup in it to pull certain information from the querys when you log into it I also a login that does this but I like this login better

if anyone can help I will email this database login to you
iraqismoker@yahoo.com

----------


## johnwatkins35

i have an interesting question.....so with this login security, i have a form with a quiz on it can i have them login like normal but only on certain occasions give them access the the link that goes to the quiz form? like for instance the admin guy has sec. lvl 1 and everyone else has lvl 2.....but can i set the sec. lvl for the quiz to say 3, and then say dec. or jan. add that lvl of sec. to the users so they can access it? i hope i didnt lose anyone...thanks

----------


## Allan Murphy

John

Yes, The access level for each user can be changed anytime by the administrator of the database by using the Add/Edit users menu item which open frm_users.

Alternatively, you could add the Quiz as a menu item to security level2 that would open the quiz, then go into the table that is used to display the menu for security level 2 in the demo version this is switchboard_lev2 make a note of the value in SwitchboardID for the quiz menu item and store in the description field (this will be used later as required). Now go back to the SwitchboardID for the quiz menu  and change the existing value to 999.

By changing the value to 999 the user will not have the quiz menu item displayed as most likely you will not have a menu page number(SwitchboardID) with a value of 999-in your current database. when you want to display the quiz change the SwitchboardID 999 to the previous value you stored in the description field. Have I lost you?

The alternative method will be more efficient than trying to change the access level for each user.

----------


## Storvagun

Hello Allan, first of all - this thread is great.  :Smilie: 

I'm trying to make DB with simple user login form and afterwards I want to apply user stamp ID on all data that is modified or created in other form. I was using your template with utility form, but I constantly ran into problems. 

This is the code part:

   DoCmd.OpenForm "UtilityF", , , , , acHidden

            Forms!UtilityF!EmpID = Forms!LogInF!EmpID



LogInF - Login form
UtilityF - Utility form
EmpID - Employe ID, AutoNumber in User table


What I get as error message is Runtime error '2448' : "You can't assign a value to this object."

Since I'm VB/Access newbie, can you please tell me what could be the problem?

----------


## Allan Murphy

Hello Storvagun

Please send me a copy of your database with just the login and utility forms and I will have a look at your problem.

----------


## sonia

Is there any way where we can use windows authentication to login the form.

----------


## sonia

> Here is my sample login screen database.
> 
> Open frm_main use either TEST1, TEST2 OR TEST3, the user ID determines the level of access. Whne you first login you will asked to change the password as the password has expired. This is a feature that I use as a bit of security etc.
> 
> Contact me if require more information etc.
> 
> Allan Murphy
> allanmurphy@unwired.com.au


__________________________________________________  _______________________________________________
Dear Allan,

have created a back end access sheet which is linked to access user form. but the location is different for both.
i have used have used  the  path  to define location for backend form. is there any way where can i use you form to save credential in my backend and users can validate their credential from there. Kindly assist.

----------


## Allan Murphy

If you want a form to manage you user credentials, then just create a form as per your requirements and then set the record source to the tbl_users in your backend database. For security reasons be careful not to allow everyone have access to this form. You will also need password and access level on this form so that you can change the access level and reset the user's password etc.

----------


## HiTechCoach

[QUOTE=sonia;132051]Is there any way where we can use windows authentication to login the form.[/QUOTE

Sure. I do that a lot.

I use this to get the Windows user name: http://access.mvps.org/access/api/api0008.htm

I look up to see if the Windows user is in a local user table. If found then I run the code to log in the user with that user name. 

I have not used it, but I have seen way to get more Active Directory (AD) information about the use, like security groups. This would allo you to make a more fully integrated security system using AD.

----------


## sonia

> If you want a form to manage you user credentials, then just create a form as per your requirements and then set the record source to the tbl_users in your backend database. For security reasons be careful not to allow everyone have access to this form. You will also need password and access level on this form so that you can change the access level and reset the user's password etc.


Thanks alot allan

----------


## sonia

[QUOTE=HiTechCoach;132061]


> Is there any way where we can use windows authentication to login the form.[/QUOTE
> 
> Sure. I do that a lot.
> 
> I use this to get the Windows user name: http://access.mvps.org/access/api/api0008.htm
> 
> I look up to see if the Windows user is in a local user table. If found then I run the code to log in the user with that user name. 
> 
> I have not used it, but I have seen way to get more Active Directory (AD) information about the use, like security groups. This would allo you to make a more fully integrated security system using AD.


but this describes user only. would like to valodate the password also from system (windows authentication)

----------


## sonia

> If you want a form to manage you user credentials, then just create a form as per your requirements and then set the record source to the tbl_users in your backend database. For security reasons be careful not to allow everyone have access to this form. You will also need password and access level on this form so that you can change the access level and reset the user's password etc.


Hi Allan,

below is code which would like to modify as per my requirement.
my requirement is to save credential in backend database named "tbl_users"
have already created tbl_users. but want to know how to address the table/file through code.




Sub display_menu()
On Error GoTo err_display_menu

' at this stage the userId and access level has been checked
Dim access_level As Integer
Dim finish_Date As Date
Dim port_syd As String
Dim valid_user As Integer
Dim check_user As Integer
Dim password_period As Date
Dim check_password As String
Dim strmsg As String
Dim Connection
Dim Rs1 As ADODB.Recordset
Set Connection = CreateObject("ADODB.Connection")
Set Rs1 = New ADODB.Recordset
Connection.Open (Databasepath)

Rs1.Open "tbl_users", Connection, adOpenDynamic, _
adLockOptimistic, adCmdTableDirect


valid_user = 2

' **********************************************
' validate user_id
' **********************************************

check_user = DCount("[user_id]", "tbl_users", "user_id=forms!frm_main!user_id")
    If check_user = 1 Then
        valid_user = 2
    Else
        valid_user = 0
   End If

' **********************************************
' validate password
' **********************************************
If valid_user = 2 Then
   check_password = DLookup("[passwords]", "tbl_users", "user_id=forms!frm_main!user_id")
   If UCase(check_password) = UCase(Forms!frm_main!password) Then
        valid_user = 2
   Else
        valid_user = 1
   End If

End If

----------


## Allan Murphy

Sonia

Would you please be more specific in your meaning of "credentials"?

If you mean add a new user to the database then it will be advisable to use a form. The code can be used to add a new user when the user id is not valid. But the question is has a valid user entered an incorrect user id or an incorrect paasword, or an employee has entered an user id in the process of obtaining unauthorised access to the database?

Using a form you are able to control the users who have access to the database.

----------


## sonia

> Sonia
> 
> Would you please be more specific in your meaning of "credentials"?
> 
> If you mean add a new user to the database then it will be advisable to use a form. The code can be used to add a new user when the user id is not valid. But the question is has a valid user entered an incorrect user id or an incorrect paasword, or an employee has entered an user id in the process of obtaining unauthorised access to the database?
> 
> Using a form you are able to control the users who have access to the database.


Allan,  user id and password is saved in backed file users have only front end, but his details are saved in backend file.now i want when ever user is entering user id and password it should match from backend file. so have attached both front end and backend, kindly do something so when ever user is entering his user id and password his details should match from the backend file. 
the frond end file name is proposal2 and back end file name is Database2.
need your attention on below. i am getting error on below.this code is written for the table which is in the same file. but my table is in split and will send u the file.



check_user = DCount("[user_id]", "tbl_users", "user_id=forms!frm_main!user_id")




Regards,
Sonia

----------


## Allan Murphy

Sonia

I would like to continue this off forum. So would you please supply me with your email address.

Me email address is allanmurphy47@gmail.com

----------


## sonia

> Sonia
> 
> I would like to continue this off forum. So would you please supply me with your email address.
> 
> Me email address is allanmurphy47@gmail.com



Dear Allan,
my email id
soniasas0190@gmail.com.

----------

