LogON Screen Example

Dina01

Registered User.
Local time
Today, 15:42
Joined
Apr 24, 2002
Messages
87
I have create a dbs in Acess and I need to create a form that I can make the user LogOn with username and ID. Does anyone have an example.......

Thanks
 
do you want the user to log onto the whole database, or just 1 form?
 
I need the user to log into the whole db...and if the db is open and a new user comes along then the other user has to lof off and the new one has to re login
 
ok try this

create a blank form, and save it calling it frmHide

create a form with 2 unbound fields UserName and Password, save it as frmLogin, take record selectors and nav buttins off, and for the afterupdate event for Password enter this code

create a table and call it Open create 1 field (text) and name it Open
use this table as the record source on the frmLogin form
create a hidden field and bind it to the Open field

then use this script on the afterupdate event for Password
Code:
If UserName <> "user" Or Password <> "pass" Then
    DoCmd.Quit
Else
    If Not IsNull(Open) Then
        MsgBox "You can not access this Database while another person is using it, please try again"
        DoCmd.Quit
    Else
        Forms!frmLogin!Open = "1"
        DoCmd.OpenForm "frmLogin", , , , , acHidden
        DoCmd.OpenForm "Switchboard"
    End If
End If


then for the on close event for the form add this line

Code:
Forms!frmLogin!Open = Null



EDIT - you will also need to change the close button property on frmLogin to no otherwise you can bypass the login.

and you will need to go to Tools>Startup and set display form to frmLogin
 
Last edited:

Users who are viewing this thread

Back
Top Bottom