Link to home
Start Free TrialLog in
Avatar of hawkeyex
hawkeyex

asked on

Static login: copying data from login to other data

I am trying to work on a static login function that looks like this. This is not your everyday login with password thing, but something like a data entry log.

The data entry log looks like this:

Date: _3/24/05_
Day: _Thurs_
Time: _7:00AM_
Oper: _MM_

And with that info, I need to set up a control table and be able to have the same info logged on to the other form as a static data entry log so it doesn't have to be retyped for each form.

If you have any questions, I will be glad to answer it.

Basically, what I'm looking for is a sort of a statement that allows me to "copy" the log information from the login screen to other forms. I need to know what's the best way to do it.

David
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Sure thing!  Create your login form with one command button on it.  Make the first form your users see upon opening the database.  When they enter their information and click the button, the OnClick event should a) check for info, b) authenticate if necessary, c) hide the 'login' form, d) open the next form in the series (presumably your switchboard..?).

As your users do their work, the login form is still open but hidden.  From the other forms, you can reference the login form at any time to pull the info they entered.
Avatar of hawkeyex
hawkeyex

ASKER

How can I reference the login form? That's what I need to know.
Forms![MyLoginFormsName]![MyControlName]

OR

Forms("MyLoginFormsName")![MyControlName]
Last question.. where do I put that in? I put it in the Default Value, and it didn't work.
You would have to assign the value to the control when you need it.  For example, before saving the record (if you have a save button as opposed to letting Access do it automatically), check to see if those fields are populated.  If not, populate them.  Or, when a new record is created, populate the fields right from the start (which has other benefits, also).  Or, when the form's OnCurrent event fires, use that opportunity to see if the fields are populated, and if not, ask the user if they want to add that data.  There are any number of ways this could be done.
Could you tell me, as a newbie, how it can be done?

David
or, in a module put this:
Date: _3/24/05_
Day: _Thurs_
Time: _7:00AM_
Oper: _MM_
Option Explicit


Public Type UserInfo
    Date1 As String
    DayName As String
    TimeName As String
    Password As String
    Oper As String
   
End Type

Public User As UserInfo

Then on your login form on the command button to enter, feed all the info into these variables like
User.Date1=Me.Date1
etc
Then, on current event of each form
Me.Date1=User.Date1
and so on

Billystyx
First, create your login form.  Obviously it will have controls for Date, Time, Day, and Operator.  The Date/Time/Day fields can have their DefaultValue property set to the appropriate functions: Date(), Time(), Weekday(Date()).  For the operator, you can either have a textbox for the user to enter their identity, or perhaps a combobox for easy selection.  You should also place one command button for submitting the login.  Its OnClick should look something like this:

Private Sub MyCommandButton_OnClick()

Me.Visible = False
DoCmd.OpenForm "TheNEXTFormTheyWillSee"

End Sub

As I said before, "TheNEXTFormTheyWillSee" is likely to be your main switchboard.  From here, the rest of the app works as normal.  When the user finally gets into a data entry form and you need to insert information from your login form, simply reference it as: Forms![MyLoginFormsName]![MyControlName]

Before asking for more information on this, give it a try.  It is a relatively simple task with no authentication.  If you run into a problem or get stuck somewhere, come back and post here, and I'll walk you through that section.  
It is partially working. The only thing that is giving me errors is this:

[Forms]![Login]![strDay] will return an #error - it is a string on Login form
[Froms]![Login]![strOper] will return an #error - it is a string on Login form

The other two (day and time) works just fine when passed as Day/Time

David
er make that [Forms]![login]![strOper] - obvious typo.
Post the code in which you are receiving the error.  The reference should work as is, just like the other two.
How? How do I show you the code?
From the Design view of the form, press Alt-F11.  Access should bring up the IDE window, directed to the module for your form.  
Here you go:

Option Compare Database
Option Explicit

Global dtDate As Date
Global dtTime As Date
Global strDay2 As String
Global strOperator As String

Function GetUDate() As Date
GetUDate = dtDate
End Function

Function GetUTime() As Date
GetUTime = dtTime
End Function

Function GetUDay() As String
GetUDay = strDay2
End Function

Function GetUOperator() As String
GetUOperator = strOperator
End Function


Oops. I see. Let me try something a bit different.

Nope. Didn't work. Any ideas?
if it helps, the login button looks like this:

Option Compare Database


Private Sub Login_Click()
dtDate = Me!dtDate
dtTime = Me!dtTime
strDay = Me!strDay
strOperator = Me!strOperator
DoCmd.OpenForm "Switchboard"
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Would it be easier if I gave you a copy of my DB so you can see what I'm having trouble with?

Still awaiting response.
It would be, but that is against policy here at EE.  How about I make a working model for you and send it through email so you can see it work?  I can post the code here for future EE searches, and you get to see exactly what I'm talking about.  Deal?  If you're good with that, put an acceptable email address in your profile.
How about if I sent you the DB via your e-mail if it works?
That will work, too, but Hotmail has been having some issues with attachments recently...the virus scanner seems to think EVERYTHING is infected.  Also, I prefer to just make something I know is clean from the start rather than patching into a project-in-progress, so to speak.  

In any case, please make a structural copy of the db with only your objects and code...remove all the data.  Compact and zip before sending.
I figured out the problem. Your solution works fine. It was a error on my part.
Glad you got it sorted out!  :)  Good luck with the rest of your project.