Full Version: Is there a way for me to create a "login" form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
HawkeyeX
And use the form to transfer their login forms into the other forms?

I'm trying to make a Daily Report form, but first I want to "log them in" first and use their following info:

DATE DAY TIME OPERATOR

into all other forms that require them and then grey that area out (so they don't have to input it again)

Make it simpler.

Any advice? I'm an Access newbie.

Thanks!

David
fredrisg
David,

I use a Sign On form (frmSignOn) that is the start up form and only has four controls: a cbo for user names,a password textbox, and a Ok and Exit buttons.

The password for each user is hidden in a column in the cbo.

When the user hits Ok or Accept, the VBA checks to see if the password is correct for the user and opens the Main Menu (frmMainMenu) (just a simple form with command buttons that go different places . . . project tracking, sales, etc.

If the password isn't corrent, the user can't enter the system.
CODE

If txtPassword = cboName.Column(2) Then
   . . . open frmMainMenu
Else
   . . . message indicating the password is wrong
end if


Steve
HawkeyeX
Problem is, this isn't what I'm looking for.

I'm looking for something simple - like a logon form to transfer the following info:

DATE DAY TIME OPERATOR

to other forms that I've created.
tinygiant
HawkeyeX,

You don't need to keep transferring the data to each of the forms you open. It would be a little easier, I think, to create a global variable on login of a custom type:
CODE
Public Type UserInfo
    LoginDate as Date
    LoginDay as ???
    LoginTime  as Date
    Operator as Integer
End Type

Global User as UserInfo

When the user logs in, you can use code to set these variables and they will then be availabe to any module, form, report, etc. etc at any time, using forms, queries or VBA. You set the variables with a statement like this:
CODE
User.Operator = DLookup(....)

or some such statement to set it's value. You can then refer to it at any time in much the same way.
CODE
Me.txtDate = User.LoginDate

I've used this technique to successfully and easily transfer values that are required in multiple areas without having to worry about setting variables in each form's module or worry about passing information from form to form.
HawkeyeX
Ok. As an Access newbie, can you help me out do this correctly? I don't know much about Access, only what I know via the books, and this is a bit advanced for me.

Thanks!

Actually, Operator is a 2 letter name so it should be text, not Integer, btw.

David
fredrisg
Hawkeye,

Here's some sample code that does what ed suggest and I do myself:

CODE


    If txtPassword = cboName.Column(2) Then                

        'obtain user and permission info
        gstrName = cboName.Column(1)
        glngNameID = cboName.Column(0)

     End if


Here again, the password is hidden in column in the cbo using a 0" width.

I establish global variables in a module as follows:


Global gstrName As String
Global glngNameID As Long

Thus, you can refer to this global variables anywhere in your code.

Steve
jhardy66
You may also want to check out CyberCow's example db Login from the Code Archives. It is what I use for the basis of my login form. Which I use for similar reasons to you. His code is veryu well documented and any questions I've ever had on it, he was always willing to help.

Also check out this link for an explaination.

Edited by: jhardy66 on Mon Mar 21 14:00:11 EST 2005.

Edited by: jhardy66 on Mon Mar 21 14:03:38 EST 2005.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.