Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Populate fields based on Log In screen

Status
Not open for further replies.

cjdecou

Technical User
Apr 24, 2014
12
US
Good Morning,

I am sure that this has been asked many times and as I am knew to doing this extensive a db creating, I have a question for you.

I have a form that I am trying to get a couple of fields to auto populate based off of when the user logs into the db. The user logs into the db using ID and Password. At that time it goes to a switchboard which then they are able to choose the form which has their Name and ID (fields to be auto populate) on it.

For the Log in screen, I have a query (User Activity User) that runs to verify both the ID and the password and the access rights (admin or User). On this query it generates the following information

ID
Username
Password.

I have tried using the following and have had no luck

[ul]
[li][/li]
[/ul]=currentUsername()
[ul]
[li][/li]
[/ul]SELECT [User Activity User].UserName FROM [User Activity User] ORDER BY [UserName]; (which gives me the inforamtion needed but ask for paremeters to be entered repeatly)

Here is some of the coding that I have and

Private Sub Submit_Click()
On Error GoTo Err_Submit_Click

DoCmd.GoToRecord , , acNext

Exit_Submit_Click:
Exit Sub

Err_Submit_Click:
MsgBox Err.Description
Resume Exit_Submit_Click

End Sub
Private Sub save_Click()
On Error GoTo Err_save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_save_Click:
Exit Sub

Err_save_Click:
MsgBox Err.Description
Resume Exit_save_Click

End Sub


Private Sub Next_Click()
On Error GoTo Err_Next_Click


DoCmd.GoToRecord , , acNext

Exit_Next_Click:
Exit Sub

Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click

End Sub


Any assistance would be greatly appreciated. Please be specific because as i mentioned before I am new to this extensive of code writing.

Chekotah

 
You can try set the login screen to invisible. Then you can reference the values of controls like:

Code:
=Forms!frmLoginFormName!txtLogin

You can also store these values in a local table.



Duane
Hook'D on Access
MS Access MVP
 
Duane,

thank you for responding. the values for the ID and username are stored on a table when the query is ran.


Confused as to the making the Login Screen invisible.

Thanks again
 
Still needing a solution to this issue.

Scenario,

Have a form that the employees enter their daily hours in (production based company), I would like to have two fields to auto populate when the employee logs into the db. The two fields are their name and employee ID.

Currently my db has it when the employee chooses the form it will ask for parameters to add their employee Id several times which I do not want them to do that. I have tried doing look ups to a query as well as a table however it still continues to ask for the parameters.

Any suggestions or recommendations on how to get the form to open with the information already populated into the fields based off their login.
 
Can we assume your login screen is an Access form that the user enters his/her employee ID? If so, don't close the login screen/form, just set its Visible property to false. Since it has the employee ID in it, you can reference the value in the criteria of a query like:

=Forms!frmLoginFormName!txtLogin

Duane
Hook'D on Access
MS Access MVP
 
Thank you Duane,

Yes the log in form is used so sign into the db. However when I set the visable property to false it does not show the form at all.

I am sure I am missing something in the above explaination.



 
Good Morning Duane,
The Log in form is used to sign into the system. I have it where it closes after they get done logging in.

I am sorry. My misunderstanding (which is not REAL hard on this project for me) what you were asking for or suggesting in the orginal thread. This project has become more exstensive than I orginally thought it would be.




 
Ok. I am attaching the form and the some other visuals for you to see.

Here is the process I would like it to do.

Logon (Login Screen attachement)
Populate the name and Employee ID fields (daily Hours Screen) without asking for parameters

Also included is the code for the Daily hours and the Log in Screen.

 
None of your attachments are available to us. You are better off just answering the questions we ask. If you really want to share a file you will need to post it on some file sharing web site and hope someone here will download and open it. Not everyone here trusts or has access to these types of web sites.

Duane
Hook'D on Access
MS Access MVP
 
Ok good to know on the attachments. Thanks.

I just want the value to appear. For now the only form using this information is the Daily hours. Of course that is subject to change later down the road.

I am not sure if this matters or not, however there several tables and queries that has all this information in it. That is why I was hoping the DLookups would work.

 
Tell us about your login form like
- form name
- name and control sources of significant controls
- code/macro to close

Which of the values from the login form do you want to use elsewhere? Do you want to use them for defaults? Are the controls where you want to use them bound or unbound?

Duane
Hook'D on Access
MS Access MVP
 


Form name is Login.

Here is the code for the Login

Private Sub Login_Click()
On Error GoTo Err_Login_Click
Dim varEvent As Variant
Dim stDocName As String

varEvent = DLookup("[UserType]", "[ID_PW_Check]")

If Not IsNull(varEvent) Then

stDocName = "Switchboard" & varEvent
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm stDocName

Else
MsgBox "User name not found or password is incorrect", vbInformation, "Warning"
End If

Exit_Login_Click:

Exit Sub

Err_Login_Click:

MsgBox Err.Description
Resume Exit_Login_Click

End Sub


Thanks again
 
How about answering:
- name and control sources of significant controls

We now know there is a close button. You could change these lines of code:
Code:
stDocName = "Switchboard" & varEvent
DoCmd.Close acForm, "Login", acSaveNo
DoCmd.OpenForm stDocName
to
Code:
stDocName = "Switchboard" & varEvent
[COLOR=#4E9A06]'DoCmd.Close acForm, "Login", acSaveNo[/color]
Me.Visible = False
DoCmd.OpenForm stDocName



Duane
Hook'D on Access
MS Access MVP
 
If you mean on the log in form, the control source is in the ID_PW_Check Query which has the following fields

ID which is their Employee ID.
PW
User Type Code
User Type

If you mean the daily hours, currently because of all the trial and errors there is not a control source. The form was created from a table which has the information.

HTH
 
Sorry, thank you for being so patient.

The control is a text box
 
Again:
- name and control sources of significant controls
Do you have only one text box?
What are their names?
What is entered into the text boxes?
Do they have anything in their control source properties?

Duane
Hook'D on Access
MS Access MVP
 
Duane.

There two text boxes that are named

ID
PW

What is entered into the text box are numbers that when entered does the lookup per the ID_PW_Check to see if it is a valid employee and Password as well as their User Type (Admin/Uder). If they are a valid employee and depending on their user type, it then opens the switchboard based off their User tye.

There is nothing in the control source(s) on the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top