?
Solved

Static login: copying data from login to other data

Posted on 2005-03-24
25
Medium Priority
?
198 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:hawkeyex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 10
25 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13626148
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.
0
 

Author Comment

by:hawkeyex
ID: 13626210
How can I reference the login form? That's what I need to know.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13626223
Forms![MyLoginFormsName]![MyControlName]

OR

Forms("MyLoginFormsName")![MyControlName]
0
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 

Author Comment

by:hawkeyex
ID: 13626331
Last question.. where do I put that in? I put it in the Default Value, and it didn't work.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13626350
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.
0
 

Author Comment

by:hawkeyex
ID: 13626519
Could you tell me, as a newbie, how it can be done?

David
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 13626761
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
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13630231
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.  
0
 

Author Comment

by:hawkeyex
ID: 13631961
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
0
 

Author Comment

by:hawkeyex
ID: 13631967
er make that [Forms]![login]![strOper] - obvious typo.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13643817
Post the code in which you are receiving the error.  The reference should work as is, just like the other two.
0
 

Author Comment

by:hawkeyex
ID: 13645911
How? How do I show you the code?
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13646271
From the Design view of the form, press Alt-F11.  Access should bring up the IDE window, directed to the module for your form.  
0
 

Author Comment

by:hawkeyex
ID: 13646296
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


0
 

Author Comment

by:hawkeyex
ID: 13646306
Oops. I see. Let me try something a bit different.

0
 

Author Comment

by:hawkeyex
ID: 13646331
Nope. Didn't work. Any ideas?
0
 

Author Comment

by:hawkeyex
ID: 13646338
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
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 1000 total points
ID: 13646479
Is the first bit of code you posted in the same module as the second bit?  Your login form's code should look like this:

Option Compare Database

Private Sub Login_Click()
    Me.Visible = False
    DoCmd.OpenForm "Switchboard"
End Sub

There should be nothing else in the module for your login form.  If those other variable declarations are in there, delete them.  They are unnecessary redundancies, and apparently use the same names as the controls on your form...never a good idea.  There will be PLENTY of code in other modules, so be careful of where you are editing.  When your users click the login button, the login form should appear to go away, but you can still reference the information they put there with these:

Forms!MyLoginFormName!strOperator
Forms!MyLoginFormName!strDay
etc...
0
 

Author Comment

by:hawkeyex
ID: 13646633
Would it be easier if I gave you a copy of my DB so you can see what I'm having trouble with?

0
 

Author Comment

by:hawkeyex
ID: 13654201
Still awaiting response.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13654389
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.
0
 

Author Comment

by:hawkeyex
ID: 13654497
How about if I sent you the DB via your e-mail if it works?
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13655771
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.
0
 

Author Comment

by:hawkeyex
ID: 13655855
I figured out the problem. Your solution works fine. It was a error on my part.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 13655892
Glad you got it sorted out!  :)  Good luck with the rest of your project.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question