Lots more questions. D:

Declan

Registered User.
Local time
Today, 18:13
Joined
Jan 17, 2016
Messages
38
Hi there!
First of all, I'm a beginner. If you're attempting to answer, please assume I have no knowledge of databases, access or VBA coding.
Key Facts:
-> Access 2013 professional plus.
-> Very Limited Knowledge of Access.
Okay. Question 1:
I have a table (tbl_Users) of users with fields containing there username (UserLogin) and their passwords (Password). I have set up so that the passwords show up as asterisks's and that they are all password. What I want, is a login form that will reference the tables usernames and passwords and depending on the result, will let them log in.
At the minute, I have worked out how to fill out a basic login form that using VBA code, either allows the user to log in, or presents them with a message. Here's a copy of the code (That works):
Code:
Private Sub Command1_Click()
Username.SetFocus
If Username = "user1" And Password = "user1" Then
MsgBox "Successful Login", vbInformation, "Central Bedfordshire Libraries Training and Induction"
DoCmd.Close
DoCmd.OpenForm "Frm_Main"
Else
MsgBox "Invalid Username/Password combination, please try again."
Me.Username.SetFocus
End If
End Sub
However, I don't want to list all of the 500+ employee's passwords and usernames within the coding, for obvious tiring reasons but also for security. Instead, I have completed a table, and want the login button to see if A. The username is in the table, and then B. if the password entered is the one matching in the table. I have looked at examples and other videos and all sorts, but it's confusing. I need someone to break it down for me. Can anyone help me with this?
Question 2:
In order for different users with different security levels to be directed to different switchboards, how would I do this? Would it be easiest to have a different table for each different security level. So that I can just make the database search for the username in table A, if found, go's to security level's A appropriate switchboard, if not, go to B, and do the same, or if not, go to C. And then check password against username in whatever table. So I'd create 3 different switchboards, is this the best option?
Question 3:
Is there a way to create automatic entries into specific fields? For example, I have managed to create a new user form for Admins, and this involves them typing the first name and last name into textboxes, Is it possible for the system to somehow take the first letter of the first name and then the whole last name of the new user and put it into a username field? As well as the names, it would have 01 next to it, however if the same name arises, then it would be 02?
For example:
Joe Bloggs, added 16/07/2016, would have the username JBloggs01.
JimBloggs, addeed 17/07/2016, would have the username JBloggs02.
Is there a way for access to automatically do this?
Question 4:
All passwords will be set as password, however I want a way for once the user to be able to change their password, for obvious security reasons. Is this possible?
Question 5:
If I want a button to move the user from a form (Form A) to another form (Form B) would I do the below:
(On the coding option on the button in form A)
DoCmd.Close
DoCmd.OpenForm "Form B"
Question 6:
Is there a way to make a button move the user from the current form to the last form they were at? I.e.
They have moved from form A to form B, but want a form of a back arrow that can lead to the last place (form, database, whatever) they accessed?
Question 7:
Is there a way to insert a gif onto a form?
Thanks for any help! It's really needed..
Declan

--

To anyone who helped on my first post, thank you, but it didn't work. Since I had other questions, I figured I'd post another thread witht hem all on it.
 
note: in your code you have code AFTER the close form. Once the form closes, it cant continue with the code.
Now the problem:
i would pass on the password storage. Instead use whats already there, use the Window login authentication. You dont need to keep track of a users password when Windows can do it. All you have to do is authenticate it using code below.
Check against the windows authentication using a form to capture the id/pass...

Code:
SUB btnLogin_Click()
Dim sUser As String, sPass As String, sDom As String

sUser = txtUser
sPass = txtPass
sDom = txtDom

If WindowsLogin(sUser, sPass, sDom) Then
   mbSafe = True
   DoCmd.OpenForm "frmMainMenu"
   DoCmd.OpenForm "frmLogin"
   DoCmd.Close
Else
   MsgBox "LOGIN INCORRECT", vbCritical, "Bad userid or password"
End If

'-----------------
Public Function WindowsLogin(ByVal strUserName As String, ByVal strpassword As String, ByVal strDomain As String) As Boolean
'-----------------
            'Authenticates user and password entered with Active Directory.
        On Error GoTo IncorrectPassword
        Dim oADsObject, oADsNamespace As Object
        Dim strADsPath As String
        
        strADsPath = "WinNT://" & strDomain
        Set oADsObject = GetObject(strADsPath)
        Set oADsNamespace = GetObject("WinNT:")
        Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strDomain & "\" & strUserName, strpassword, 0)
        WindowsLogin = True    'ACCESS GRANTED
ExitSub:
        Exit Function       
IncorrectPassword:
        WindowsLogin = False   'ACCESS DENIED
        Resume ExitSub
End Function
 
Your questions are incompatible with the level of Access aptitude you want us to assume of you. What you want to accomplish requires a medium level capability. You can't expect to post on an electrician forum, tell them you barely know the difference between a 9 volt battery and a AA and ask them to tell you how to rewire your house.

With that said, I will give you answers to your questions, but probably not at the level you probably want. I would recommend googling the functions and keywords I mention to find out how they work.

1. You would query your user/password table to see how many records have that combination. You would do this in a DCount. If its 1, they supplied good credentials, if not its bad.

2. It depends on how different the switchboards are. My advice would be to create 3 initially, but then if you see they are similiar see if you coudl combine them. You might have to hide some features (Visibility Property= False) and possible use VBA to rename some options.

3. Yes. You would use an AfterUpdate or OnNew or some similar 'event' to capture the user's action to trigger some code. That code would then compile a possible username using your rules, validate it against existing ones and then show it on screen to the appropriate field.

4. Yes. I believe it would work just like any input on a form would--it just wouldn't show the value.

5. I find its best to Open, then close. Especially if you want to use a value on the existing form--if Form A has an ID you want to use to open Form B, well then Form A must be open to retrieve that value.

6. Yes, and this reinforces my point in #5. If you want to know the prior form, you would need to pass that information to the new form. You could set it in a variable (Dim LastForm As String). Then if they click the appropriate button you can use that variable and open that form.

7. Yes. One of the format properties allows a backgroudn image.

Again, what you want isn't beginner level stuff, so to give you the answers you want at the level you want would require a 2000 word post. I gave general answers and I'm closing i on 400 words.
 

Users who are viewing this thread

Back
Top Bottom