473,836 Members | 1,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multi user login screen - question about tracking logged in users

44 New Member
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 access to a form called manager1. I have used the following code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Private Sub Login_Click()
  3. UserName.SetFocus
  4. If UserName = "Staff1" And Password = "Staff1" Then
  5. MsgBox "Welcome"
  6. DoCmd.Close
  7. DoCmd.OpenForm "Staff1"
  8. ElseIf UserName = "Staff2" And Password = "Staff2" Then
  9. MsgBox "Welcome"
  10. DoCmd.Close
  11. DoCmd.OpenForm "Staff2"
  12. ElseIf UserName = "Manager1" And Password = "Manager1" Then
  13. MsgBox "Welcome, please exercise caution when changing query or table conditions", vbInformation, "CDSignatures"
  14. DoCmd.Close
  15. DoCmd.OpenForm "Manager1"
  16. Else
  17. MsgBox "Please re-enter Username and Password"
  18. End If
  19. End Sub
  20.  
My question is how can I track users once they have logged in. I have a database which tracks data that has been editted from the main database and I would like to know how to show which user has done this.

Thanks in advance.
Oct 29 '12
55 9735
anewuser
44 New Member
I did not mean to cause any offence going back to If...Then...Els eIf. I just wanted to try to fix the problem myself before asking for more help (and that was the only way I knew how). Sorry. For the record I have no preference.

In any case it still isn't working when I click the login button nothing happens...
Nov 9 '12 #21
NeoPa
32,584 Recognized Expert Moderator MVP
It's not a question of offending per se. I was just confused by your changing what I'd already provided for you. If I see you taking a course that seems ill-advised then I, as an advisor in this situation, feel bound to bring that to your attention. In effect, your reason was a sound one anyway, but it may have made better sense to return to where we both were before posting it. That way we can continue to focus on the actual problem and not get side-tracked by other changes that can only be a distraction.

DLookup() doesn't return a String value, but rather a Variant which is generally of type String. When no matching record is found then the result is Null. Null is not a String value and, as such, cannot be compared to other string values. I can only assume that my suggested code (I'm not able to test it so I have to do it all in my head) is still not handling the Null value adequately. I should have used Nz() in line #11, and I will proceed to do so now. BTW Line #11 from your post #19 will crash if no record is found as String variables cannot be assigned the value Null.
Nov 9 '12 #22
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Just for info:
If you prefix a table with usys it automatically becomes hidden and is considered a developer implemented system table.
Nov 9 '12 #23
NeoPa
32,584 Recognized Expert Moderator MVP
Well. I didn't know that Smiley. Very interesting indeed. I'm already thinking about where i've used normal tables that could be better handled by such tables. Thanks :-)
Nov 9 '12 #24
anewuser
44 New Member
Hi, the amended code still isn't working. I don't know there is any more information that you need or if there is anything that I can do to test the current code other than trial and error (which I am currently doing).

For what it's worth I have just tried all of the usernames and passwords currently set up in tbl_User each one tests the different cases and one which is not in the table and each time nothing happens.
Nov 12 '12 #25
zmbd
5,501 Recognized Expert Moderator Expert
From the other posts, it sounds like there have been quite a few modifications since the last posting in thread at #19.
Please post your current code.

What I would do is place a STOP command after the line strCase = DLookup("[Regular] & [Admin]", "tbl_User", strSQL) (based on #19's code block)
Compile and save.
Start the process to log-in.
Make sure you use a valid username/password
when the parser hits the STOP you will enter break/debug mode...
<Ctrl-G>
In the immedate window:
?strSQL
Please post the resolved string. Most errors when returning values such as this involve a malformed string.

Continue to step thru your code using [F8] and note what branch in the conditionals is being taken... second most common error is a malformed logic statement.

when you step thru: strSQL = Replace("UPDATE [usyscurrentuser] SET [CurrentUser]='%N'", "%N", Me.UserName)
Once again please obtain the string as before In the immedate window: ?strSQL.


Repeat this for a valid-user/wrong-pw
Repeat for invalid-user/wrong-pw
Repeat for invalid-user/valid-pw


Post all of the strings along with the updated code.
Nov 12 '12 #26
NeoPa
32,584 Recognized Expert Moderator MVP
The most important information we need at this juncture is an explanation of what "nothing happens" means. No messages seen? No data updated? No form opened? Please be as clear as you can.
Zmbd:
Please post the resolved string. Most errors when returning values such as this involve a malformed string.
That's my code you're talking about Z! Surely you don't suspect it of creating a malformed string :-D

More seriously, the instructions Z gives are very worthwhile following (Even the ones about malformed strings. Of course it's possible for bugs to get in there). Nevertheless, it is also important to have a clear idea of exactly what is meant by something not working, so that info too, would be helpful.
Nov 12 '12 #27
zmbd
5,501 Recognized Expert Moderator Expert
NeoPa: That's my code you're talking about Z! Surely you don't suspect it of creating a malformed string :-D
From you never, from the Gremlins that play with the datatables... always! Especially those elusive twin Gremlins of Null-n-Empty - nasty little beasties, yessssss my precious.... nasty little beasties they are!

(ROTFL)

oh.. how to get back on topic... sigh... OH Yes... I'm looking for something that is letting one of the Gremlins muck up the string or for the logic to fail which is why the request for the latest version of the code.
Nov 12 '12 #28
anewuser
44 New Member
Hi my current code is:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub Login_Click()
  5.     Dim strSQL As String, strForm As String, strMsg As String
  6.     Dim dbVar As DAO.Database
  7.  
  8.     strSQL = "([UserInitials]='%I') AND ([Userpassword]='%P')"
  9.     strSQL = Replace(strSQL, "%I", Me.UserName)
  10.     strSQL = Replace(strSQL, "%P", Me.Password)
  11.     Select Case Nz(DLookup("[Regular] & [Admin]", "tbl_User", strSQL), "")
  12.     Case ""                 'No matching record found
  13.         Call MsgBox("Please re-enter UserName and Password")
  14.         Exit Sub
  15.     Case "00"               'Both FALSE
  16.         strMsg = "Welcome"
  17.         strForm = "Staff1"
  18.     Case "-10"              'Regular TRUE; Admin FALSE
  19.         strMsg = "Welcome"
  20.         strForm = "Staff2"
  21.     Case "0-1", "-1-1"      'Admin TRUE; Regular EITHER
  22.         strMsg = "Please use caution when changing the conditions of " & _
  23.                  "tables and queries."
  24.         strForm = "Manager1"
  25.     End If
  26.     Set dbVar = CurrentDb()
  27.     strSQL = Replace("UPDATE [uSysCurrentUser] SET [CurrentUser]='%N'", _
  28.                      "%N", Me.UserName)
  29.     Call dbVar.Execute(strSQL, dbFailOnError)
  30.     Call DoCmd.Close
  31.     If strMsg > "" Then
  32.     Call MsgBox(strMsg)
  33.     Call DoCmd.OpenForm(strForm)
  34. End Sub
My question is I have tried putting stop after the Nz(DLookup...) line and have also tried putting a codebreak point on this line. I have just tried a correct username and password and tried to login. However, the debugging mode did not activate at any point have I done something wrong?

To clarify when I say "nothing happens" what I mean is that when I click on the login button - no messages are displayed, no data is updated and no forms are opened.
Nov 13 '12 #29
NeoPa
32,584 Recognized Expert Moderator MVP
Good work.

You're unfortunate in that the Stop you put after line #11 won't work because it is a Select command. It's a little bit like putting it after an If command, only even more complicated. You followed the instructions well, but came unstuck through no fault of your own. The instructions were good for the previously posted code, but not for this.

Here's a new set :
  1. Put a Stop command before line #11.
  2. When code execution stops run the following commands from the Immediate pane of the VB Editor and post the results back in here :
  3. Expand|Select|Wrap|Line Numbers
    1. ?strSQL
  4. Expand|Select|Wrap|Line Numbers
    1. Set db=CurrentDb():?db.Name:Set tdf=db.TableDefs("tbl_User"):?tdf.Name:For Each fld In tdf.Fields:?"[" & fld.Name & "] ";:Next fld
  5. Expand|Select|Wrap|Line Numbers
    1. ?"'" & Nz(DLookup("[Regular] & [Admin]", "tbl_User", strSQL), "") & "'"

This should give us most of the information we require to see what might be going wrong.
Nov 13 '12 #30

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

Similar topics

1
1750
by: Job Lot | last post by:
In a multi-user environment, how would I prevent users from adding Orders with identical OrderID. For instance I have following tables in my database Order ================== OrderID Identity field CustomerID OrderDate DeliveryAddress
1
2608
by: Marcin Zmyslowski | last post by:
Hello all! I want to create a page in ASP language which gives me information about currently logged users. I thought to do it by this way: when somebody will log in to page, there will be a value of this user id stored in the table among the other fields in the form which are filling in. After clicking on the button "Log off" the value of the user id will be deleted from the MS SQL Server 2000 database. I would do it, but I don`t know...
9
2572
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a header frame and a main frame. When i enter the application, i see the login screen on the whole screen, but when the authentication expires, the login screen appears on both frames.
2
1646
by: planetthoughtful | last post by:
Hi All, I'm returning to coding in Access after a break of about 4 years, and designing a multi-user app split between a front end mdb for forms / code etc and a backend mdb for tables. I'm curious about how others persist information such as login IDs etc while each user is logged in. Previously I've used a hidden form with text fields on it to keep this information persisted, but I'm wondering if anyone would suggest other methods?
2
5549
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I found a zillion messages about auto increment and read some of them but it's confusing. Can someone point me to a simple custom auto increment example that I can download? Thank you, john
3
2453
by: bala | last post by:
Hi Gurus The scenario A MS Access frontend application with Oracle Backend (Linked Tables). The Database UserID and password is not stored and each user has a unique UserID and password. There is no common database UserID and password. Each time the user logs in, the DSN UserID and Password screen is displayed. It has three input box and they are
4
1566
by: TJO | last post by:
Can someone advise about feasibility of passing user credentials to an asp.net 2.0 application using query string or other techniques? I want to avoid the login screen. Thank you.
3
1794
by: freee8896 | last post by:
Can nyone help me with this multi user login from the same system. Multiple users must be able to login from the same system at a time.... in PHP. Sessions must be used. Please donot suggest these following methods. 1 . Using a session cookie and passsing a unique id for each user using GET method. This fails when the url breaks at some page. the next page from then its not propogated. 2.Storing the users logged_in in the database n creating...
11
13743
Stang02GT
by: Stang02GT | last post by:
I am in the process of creating a database for a "Team" here at work. One thing that needs to be incorporated with this database is each user will have a log in and password I know how to do that. What I am not sure of is, I need the "Team Lead" to have Access to reports and different forms when he logs in. The other users should not have access to these items. Is it possible to assign user permission in access?
4
7452
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 situation, maybe just need a second set of eyes on this. i am in the military and have designed a unit database that allows for all kinds of tracking and reports generation for training meetings to licensing of soldiers on equipment and other...
0
9818
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9668
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10843
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10546
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10589
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9371
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
3
3112
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.