More ULS stuff

csdrex87

Registered User.
Local time
Today, 14:07
Joined
Jul 1, 2009
Messages
66
So I have modified the basic user level login script to fit my database and have come to a problem that i need help solving. What i currently have is a user password and access level in my employee information table. When they login it checks the password and then logs the user and the access level in a hidden form. This then is used to restrict or permit access throughout the database.

My problem with the code is twofold. One... if the user is smart enough to right-click the hidden form and close it the code blows up upon attempting to find the access level. "Run-time error2450" which basically states that when it ran the macro it couldnt find the required information.

The second problem that i run into is more of a basic restriction question. When restricting access what is the difference between an Add-Only and an Administrative property? I understand that read only doesnt allow any changes to the database but would an Add-Only user be restricted to opening any form that he or she desired? and how might that be achieved?

I appreciate your time as this question might be poorly worded and has a lack of code for purposes of not wanting to paste my entire database up here.
 
Actually I solved my first problem by inputting an OpenForm "UserLoginAccess" form command at the beginning of the login if statement.

The second question still stands however. After some thinking would i have to limit the access on each of the commands that the user would be doing for an Add-Only User or is that already implemented in 2007
 
Actually I solved my first problem by inputting an OpenForm "UserLoginAccess" form command at the beginning of the login if statement.

The second question still stands however. After some thinking would i have to limit the access on each of the commands that the user would be doing for an Add-Only User or is that already implemented in 2007
There is no "add only" user in Access 2007, so you basically have to code things to allow whatever. You can give them a form and open it as Add Only by basically doing something like:

DoCmd.OpenForm "FormNameHere", , , , acFormAdd

And
Forms!YourFormNameHere.AllowEdits = False
Forms!YourFormNameHere.AllowDeletions = False
 
I think I have to revise my assessment of the acFormAdd part. It will let the user add or edit records, so you would need to use the AllowEdits code instead.
 
Ok so I keep running into problems with my code :-( . This time I'm trying to add in another aspect in case there is no initial password for the user. For the first time login i have them input a password anyway and then it pops up a messagebox. This works great. When the message box attempts to do an update query on the table it goes bonkers. The problem im getting is "Error 3061:" (which im sure u dont know off the top of your head) but it also goes on to say "there are too few parameters: Expected 1" I'll post the segment of code that relates to where the problem is

If DCount("[Emp_Lname]", "tblEmployeeInformation", "[Emp_Lname]='" & Me.txtUser & "'") > 0 Then
If IsNull(strPWD = DLookup("[Emp_Password]", "tblEmployeeInformation", "[Emp_Lname]='" & Me.txtUser & "'")) Then
If MsgBox("Are you sure you want to create your password?" & vbCrLf & _
"Please write down your current password in a safe place", vbQuestion + vbYesNo, "Cancel Confirmation") = vbYes Then
CurrentDb.Execute "UPDATE tblEmployeeInformation SET " & " Emp_Password= '" & Forms!formUserLogin!txtPWD & "' WHERE [Emp_Lname] = " & Me.txtUser
End If
End If


Thank you for all your help and I understand if you dont want to answer this question cause it may seem like you are writing this for me. But I wish you would :-)
 
Well, the first thing that jumps out at me is

[Emp_Lname] = " & Me.txtUser

which should have quotes:

[Emp_Lname] = " & Chr(34) & Me.txtUser & Chr(34)

you could use single quotes, or triple double quotes (""") but I think it is easier to see with the Chr(34) and you shouldn't use single quotes where Last names are in play because someone named O'Brien or O'Reilly will kill the code due to their single quotes.
 
Fair enough. I suppose i should have thought about that.
 
Haha wow. That solved it -.- Sometimes i hate computer code... i really do!
 

Users who are viewing this thread

Back
Top Bottom