473,388 Members | 1,405 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Need advice on how to solve user log-in to open tables that's filtered by username

Hello,

I need some advice/help into solving an issue I have with user log-in. Currently, I have a working log-on screen with password that's linked to a table. Once password is entered correctly, the form opens with a text box naming the username.

Here are my issues:
  1. The issue is, once the main form closes, the link between the two gets severed and I get an error (username is not populated in the textbox anymore. Here's the code I use
    Expand|Select|Wrap|Line Numbers
    1. [Forms]![frm_tools]![txt_user1].Value = [Forms]![frm_logon]![cmb_user].Value
  2. I was going to use this link to filter the data from table based on user log-on. (e.g. log in as A, then the form opens to a datasheet with only data filtered to A.)

    The goal is having this database as multiuser so 5 or so user can log-on then opens the same form with prefiltered data based on log-in information.

Thank you in advance!
Feb 11 '15 #1
5 988
Rabbit
12,516 Expert Mod 8TB
Store the logged in user in a global variable and use a function to return the logged in user to your queries.

On a side note, I would be remiss if I didn't warn you about the security of Access, there's practically none. This storing of users and passwords is something any of your users can easily bypass. I hope that at the very least, you are storing the passwords as a hash and not in plain text. If it's in plain text, you have now potentially leaked everyone's passwords to everyone else. And since most people use the same password for everything, other people may now know the password of your user's sensitive accounts, such as bank accounts. Even if you stored it as a hash, those are easy to break if you don't use a salt.
Feb 11 '15 #2
Thank you. I had a feeling access doesn't have very good security so I was thinking of just adding dummy passwords. The goal is really to use that user name into filtering the tables opened so that I don't have to make a multiple queries per user. Could you provide examples?

Thanks.
Feb 11 '15 #3
jforbes
1,107 Expert 1GB
If all you need is the currently logged in Windows User, you might want to use this code that can be found easily enough on the Internet:
Expand|Select|Wrap|Line Numbers
  1. Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  2.  
  3. Public Function GetWindowsUser() As String
  4. On Error GoTo ErrorOut
  5.     Dim sTemp As String
  6.     Dim lCnt As Long
  7.     Dim lDL As Long
  8.     Dim sPos As Single
  9.     Dim sUserName As String
  10.     Dim txtUsername As String
  11.  
  12.     'Get the Windows User Name
  13.     lCnt = 199
  14.     sTemp = String(200, 0)
  15.     lDL = GetUserName(sTemp, lCnt)
  16.     sUserName = Left(sTemp, lCnt) & lCnt
  17.     sPos = InStr(1, sUserName, Chr(0))
  18.     If sPos > 0 Then
  19.        txtUsername = Left(sUserName, sPos - 1)
  20.        GetWindowsUser = txtUsername
  21.     Else
  22.        GetWindowsUser = ""
  23.     End If
  24. ExitOut:
  25.     Exit Function
  26. ErrorOut:
  27.     Msgbox err.Description
  28.     Resume ExitOut
  29. End Function
That way you can skip the login screen.
Feb 11 '15 #4
Well not use the windows log-in information. I want to use the log-in information from table which is a selection in a combo box.

For example, user logs in selecting username: A123. He then enters password as: pass. Then as he logs in, a table opens filtered to only show data for A123 username.

I'm trying to research global variable and it looks like it's gonna work. I just don't know how to declare or use the tl_users table as the reference for user.

Would tempvar be better than global variable?

Thank you.
Feb 11 '15 #5
Nevermind. I used tempvars and it works!

Expand|Select|Wrap|Line Numbers
  1. Function Log_in()
  2. On Error GoTo Log_in_Err
  3.  
  4.     With CodeContextObject
  5.         If (Not IsNull(.cmb_user)) Then
  6.             TempVars.Add "UserName", .cmb_user
  7.             DoCmd.Close , ""
  8.             DoCmd.OpenForm "frm_tools", acNormal, "", "", , acNormal
  9.         End If
  10.     End With
  11.  
  12.  
  13. Log_in_Exit:
  14.     Exit Function
  15.  
  16. Log_in_Err:
  17.     MsgBox Error$
  18.     Resume Log_in_Exit
  19.  
  20. End Function
Then use this on the following form. Inser the code in the default value of textbox or objects you would like to use.

Expand|Select|Wrap|Line Numbers
  1. =[TempVars]![username]
Feb 11 '15 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bennett Haselton | last post by:
I'm looking for a PHP tutorial that specializes in how to build sites that are based around user logins. i.e. the user logs in on the front page, and are taken to a main login page where fields on...
0
by: yui | last post by:
Hi I am very need an advice for this. I am new to ASP.NET C# / VS2003 here is my sql command SELECT tblStudentCourse.CourseID, tblStudents.StudentID, tblStudents.FirstName,...
15
by: bb nicole | last post by:
The company profile showed blank after user login and click the company profile button. Supposed the company profile should not be blank and will show the company information which call from...
2
by: antonyliu2002 | last post by:
I am testing ASP.NET 2.0 Forms athentication with user credentials in SQL Server 2005. I don't want to put user credentials in web.config, so the credentials section is commented out. The...
22
by: klenwell | last post by:
I'm in the process of refactoring the php code base I've amassed over the last few years into an object-oriented framework. I'm about to start in on the authentication/login extension and I've...
4
cobra35y
by: cobra35y | last post by:
Good Afternoon, I am new to the world of programming. after reviewing this site for info pertaining to my situation, i have declared a loss and posting for help. maybe i am just overlooking the...
0
by: patiencer | last post by:
Hi! Can you help me a effective source code of user login with ms access as your database i already set the data adopter, dataset, datasource and whatsoever. I just need to get how to call the MS...
5
by: anewuser | last post by:
I currently have a working multi user login form in access 2007. It automatically redirects people who login to a user specific form e.g. user = staff1 is moved to form staff1 and manager1 is...
55
by: anewuser | last post by:
Hi, I currently have a working multi user login form which automatically directs users to the relevent forms e.g. general staff have access to a form called staff1 and staff2 whereas managers have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.