Link to home
Start Free TrialLog in
Avatar of StanKobrin
StanKobrinFlag for South Africa

asked on

User Recognition In Access Without Login

Hi Experts

I have a difficult question which I am awarding top points for advise on how to implement the following user requirement:

INFO:
I am designing a database for 3 users. Two of the users will use desktop PC's and the other uses a Laptop.
All three users will access the database from a network share (via a mapped network drive) When user 3 (the laptop) leaves the office, he/she opens a database replica, synchronises it and then can work while away from the office. When he/she returns, they synchronise the database and user 3 returns to using the local (master) copy of the database.

REQUIREMENT:
The request from the users of this database is this: much like EE's website (and other sites using cookies) when you log into the website it remembers who you are and displays your name and details automatically.

What the users of this database want is that when they log into the database it recognises them as a particular user and when creating records in the database it automatically assigns that record to the user.

They particularly don't want to have to log in when opening the database.

However, what they need to be able to do is - change the current user of the database if for some reason one of the other users is using another user's computers.

- - - -

If the above is not possible, then I will have to implement a very simple login option (without passwords) but still need to automatically assign records to the active user.

If anyone can help me implement either of the two options (preferably the first one) I'd appreciate it.

Thx In Advance

Stan





ASKER CERTIFIED SOLUTION
Avatar of jjafferr
jjafferr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StanKobrin

ASKER

Hi Jaffer

Thx for the quick reply.

I understand the Part2: Record option fully. However I am a little confused as the the login part. Could you give me some more info regarding this?

1. What is the /wrkgrp option?
2. Where does the /user and /pwd come from?

Thx again!

Stan
Am I supposed to split the dabast into a front-end and back-end? If so how would I got about doing this? I have never implemented this type of system before?

Any help would be appreciated.

Stan
Nothing to do with splitting.

This is the normal security setting of Access.

So when you secure your mdb, you make a workgroup (wrkgrp),
and them assign a user name (user),
and assign a password for the user (pwd).


let me know if you need help in guiding you how to do that.

jaffer
in Access2k
menu bar > tools > security > user level security wizard

this will do it for you.
PLEASE BACK UP YOUR DATA BEFORE YOU DO THIS

AND DO IT ON A BACKUP FIRST
You might lock yourself out of your mdb, and you might not be able to log in again, if you did anything wrote,

Thus doing it on a backup as a trial, will take away all the problems if you got locked, you simply delete it, and start again on another backup until you get right.

got it?

jaffer
Sounds easy enough.

I will give it a try and let you know the outcome.

Thx Again

Stan
How about using windows authentication.. ie. using the windows login info.

You can get who is currently loged on to windows with

Dim sUser as String
sUser = environ("UserName")

>> However, what they need to be able to do is - change the current user of the database if for some reason one of the >> other users is using another user's computers.

This is note how cookies work, unless you lick LOGOUT

Cookies are set to the Windows User also (have a look in your cookies directory and they will all be

UserName@someSite.com

So if they want to change, maybe you could have a LOG-OUT button, and if they choose to change users, then they can just "login" as another name

Full example

Create a new Module:

Public sUser as string
Public Function GetUser()
    sUser = environ("UserName")
End function

'Now you can call this function to set the windows user to the public string sUser (ie can be used in any code now) in the the AutoExeC Macro (if you dont have one of those, then create a new Macro, Call it AutoExeC and from this drop down list select RunCode then type GetUser() in the box down the bottom.)

To cahnge users, create a new form with a textBox (Ill assume its called txtUser).

Then Add a new button (ill assume cmdUpdateUser) and add this code

Private sub cmdUpdateUser_click()
If IsNull(Me.txtuser) then
  'nothing is entered, warn them
  msgbox "Nothing entered, please try again!", vbcritical, "No user Name"
  exit sub
else
  sUser = Me.txtUser.Value
end sub


Idea???!???

Dave
Tips I learend:
1- Don't use the System.mdw as your security workgroup.
2- Name your security workgroup the same name as your mdb, this way you won't get confussed if you make other mdws for other mdbs.
3- Save the mdw in the same folder as the mdb, this way you won't have to worry about netwrok access to too many folders.
4- Don't use jaffer.mdw as it is my trade mark ;o)

jaffer
Man!!!, Dave, you do come up with some nice wild ideas. LOL

but is Workgroup required in this case?
Well, I think it should, not only for the login, but also for the data security (sort of) and user access level.

jaffer
data security - in the Access TA - LOL!!!!

You can do your own User access on the fly in VB..

Ie

have a table with all users
have a "access ID" - example 1 = Admin, 0 = read only


Then something like (form code)

Private sub form_load()
Dim lAccess as long
lAccess = dlookup("[AccessID]", "[UserTable]", "[UserName] = '" & sUser & "'")
If lAccess <> 1 then
  Me.cmdDelete.enabled = false 'disable button
  Me.AllowEdits = false 'cant edit values

etc... etc....

end if

I use VB for all that sort of stuff... However, i can write VB in my sleep, and i now how much pain can be caused by using mdw's etc....  I stick to what i know....

Dave
 



I have another suggestion:

Use the module from
http://www.mvps.org/access/api/api0008.htm
to return the login name.

Have a table with a list of authorised login names and other user details.

On the form load event, simply call FosUserName function.
If the value isn't in your table list, don't allow them access.
If it is, you can pull any linked details from teh table to display.
That api returns the same as Environ("userName")
Dave,
How do you set your security, and secure the db?

jaffer
Well considering i am not a DBA and i only do it for 'fun'....

Dave's Access "Security" 101

1. FE{MDE with passwords {if needed} - otherwise only view data} / BE with shift bypass off - password prompt to use shift - startup in BE set to show nothing

2. If someone were to decide to "break in" and start to cause pain, then its their job on the line not mine.

This is the same level of security the DBA's use for the access db's..  Generally ppl have NO IDEA what is going on anyway..

If i were to do something that needed to be "water tight", id use the corperate Oracle servers,  and not pretend to do it in Access.

Dave

> BE with shift bypass off >> Got this part
> password prompt to use shift >> Do you store them in your own Table?
> startup in BE set to show nothing >> please explain this part.

thanks

jaffer
>>Do you store them in your own Table?

nope, in code.. you can still get to tables with File - Get External Data  - Link / import... and yes i know this can be also "got" by the same method, but id say even less ppl would know who to read VB... not that hard though anyway....spose you could make the BE a MDE....

ie

form...

If Me.txtPassword = "myPassWord" then
   'ok - do what ever
else
  Msgbox "Get lost!"
end if

>>please explain this part

Tools - Startup - and turn every thing off.. - just like you would normally (well i do anyway)

Later jafer, i have to go out for dinner.... getting blasted from the missus...

Catch you tomorrow...

Dave

> password prompt to use shift >> Do you store them in your own Table?

Basically exaactly the same as the DisaableShiftByPass sample db that's going around.,..  I have it uploaded but i can remeber where..

Do a search on ee for  sustomers.tripod.com <- its there somewhere if you want it and have posted it several times..

Dave
Avatar of will_scarlet7
will_scarlet7

A suggestion from someone who does not use secure databases (so it can be taken with a grain of salt):

    Using the "Environ("userName")" you could make a login screen with the option of "Remeber Me" it then stores the user name and login name in a table and when loading first checks the user name against the table to see if it has a login stored for that user, if not popup login screen. Users can then logout and re-login as another user on the same machine similar to EE.

    I've got several scripts that I can share that I think would be useful in building such a system.
will_scarlet:

I am very interested in your "remember me" solution. Not for this database though - but I am about to begin work on a system that would benefit greatly from that feature. I would appreciate any info you have on it.

I will create another question called "Remember Me Login Solution" where I can award you points for any help ( no reason why you should provide such a solution without reward!)

Stan
Jaffer:

I am accepting your answer as it was the easiest to implement and I got to learn a lot about access user security - something I have never bothered to look at before now!

I have only one query regarding this solution:

As a stand-alone database your solution works fine. What happens if I create a replica of this database?
As mentioned, one of the users will keep this db on their laptop and would like to keep an "offline" copy of the database which she could synchronise with the Master when she returns to the office?

Will the workgroup file / user/password option still work with the replica or will this create problems on synchronisation?

If it will not work, then I need away to copy the database to her local drive and make the database read-only - so at least she can read the current data in the database. It doesnt matter if she loses the login option as she wont be creating new or editing records?

Thanks again for all your help!

Stan


On a more general note:

Thank you to all who have contributed here today. I have learned a lot from all of you and am proud to be a member of EE!!

Thanks!!

Stan
Copy your mdw to the Laptop, to the same folder as the mdb,

On the Laptop have 2 shortcuts,
One for the office, where the mdw path points to the network mdw,
One for the Laptop, where the  mdw path points to the folder where it is saved,

OR
the Laptop can always point to the Laptop mdw,
the draw back is, if the office mdw was updated with more users, OR changed the security setting of the users, the Laptop mdw will not be updated.

jaffer
Stan,
    After you post your "Remember Me Login Solution" question post a link to it here so I get a notification and don't miss it.

God bless!

Sam
Stan

if she will NOT add or edit records, then you don't need the option I gave you,
just have a normal shortcut to the mdb.

I really feel small compared to all you guys who contributed to this question, AND learned alot too,

Thank you all,
and thanks Stan for the points and the grade,

jaffer
Jaffer:

Its a pleasure - the points and grade were well deserved!

I have telephoned the client (on a Sunday afternoon here in Cape Town, South Africa no doubt!) and she is OK with only a read-only copy of the database.

How would I do this?

When she leaves the office does she just copy the original .mdb file to her notebook (and not the .mdw file) or will this give errors on opening? (when I open the .mdb file directly I get an incorrect "permission error"

Or will she still need a copy of the .mdw file on her local machine with another off-line shortcut?

Stan
Stan

Yes she will have to copy (over write the existing one) the mdb to her Laptop everytime she leaves (to keep the mdb on the Laptop updated),

if you get that error message, then I guess you will have to copy the mdw and have another shortcut.

Very interesting, Clients work on Sundays!!!

jaffer
The copying is not a problem:

I am assuming I can just create a batch command to copy the database file and the .mdw file from the network to her local machine?  (this shouldn't effect the original file or the other users will it?)

The client isn't actually working... but I insist on taking all my client's mobile numbers so in case of emergencies I can contact them!

Since they wanted a demo version of this db working by tomorrow - I figured it was an emergency :)

Stan
>this shouldn't effect the original file or the other users will it?

No it will not.

jaffer
Hi Jaffer

I have the solution working absolutely perfectly at the moment, but the users have asked if I can add one more feature:

They are logging in using the /workgroup option with the user: and pwd: set in (security is not important in this db).

They would like a button in access that logs them out (the current user) and brings up the login window (username and password dialog) for them to change users without closing and re-opening access?

Is this possible? and if not - can we programatically close access, re-open it using the workgroup option - but without the user and pwd options filled in?

Thx Stan!
Hi Stan,

Glad everything is going OK.

use this code On Click of a command button to "close access, re-open it using the workgroup option "

Shell "C:\Program Files\Microsoft Office\Office\msaccess.exe  c:\YourPath\Your.mdb", vbMaximizedFocus
DoCmd.Quit

please let me know if works OK. OK!

jaffer
Hi Jaffer

I placed the code in module called LogIn(), and ran it from a macro called macLogin using the following code:

Function LogIn()
Shell "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE  W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus
DoCmd.Quit

End Function

I had to change the location MSaccess.EXE (obviously due to the version (11) of access)

It works absolutely perfectly. It runs a bit slow the first time you run it, but thereafter it seem fine.

My next logical question:

How can I write this code so that version 9 through 11 can all use the same function?

Thx Stan
For that I would recommend using an if loop with the command written specifically for each version.
Aha,
you should inquire with the system for the Office version you have, then put it in code either,
Directly in code OR in a select case OR if statment.

OR use this code which doesn't require to tell which will automatically run the program based windows registry.

Application.FollowHyperlink "W:\Work\PGCallLog\PGMsg.mdb"
DoCmd.Quit


jaffer
Hi Jaffer

Your second option - .FolowHyperlink just closes Access - it doesn't re-open it?

I would prefer to use the first method though - but not sure how to check the office version. Could you post some info on how to do this?

Stan
Stan the function below will return the current version of Access as an integer:

Function GetVersion() As Integer
    Dim myAccess As Object
    Set myAccess = New Access.Application
    GetVersion = myAccess.Application.Version
End Function
I forgot to clean up the object at the end:

Function GetVersion() As Integer
    Dim myAccess As Object
    Set myAccess = New Access.Application
    GetVersion = myAccess.Application.Version
    Set myAccess = Nothing
End Function
Hi Sam

The GetVersion worked perfectly on my Office 2003 machine, but when I ran it on a 2K machine it gives a
"runtime error '438': Object doesnt support this property or method"?

Any ideas?

Stan
The 2K machine is Access 2000 (9.0.2720)

Will installing SP3 sort this problem out?

Stan
here you go Stan

GetVersion = SysCmd(acSysCmdAccessVer)
To determine the version of Microsoft Access used to open this application.

• 8.0 = Access 97
• 9.0 = Access 2000
• 10.0 = Access 2002(XP)
• 11.0= Access 2003

Private Sub command1_Click()

select case GetVersion()
 case "8.0" , "9.0"
    AccessPath="C:\Program Files\Microsoft Office\OFFICE\MSACCESS.EXE"
 case "11"
    AccessPath="C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
End If

Shell "AccessPath W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus
DoCmd.Quit

End Sub

Function GetVersion() As String
    GetVersion = SysCmd(acSysCmdAccessVer)
End Function


jaffer
How Bizzar! Access is practcaly the only program in the Office 2000 suite that does not support the .Version method (not sure if that was fixed in SP3, but trying to find out). I guess you should stick with Jaffer on this one. Sorry.
Runtime error '53': file not found

Shell "AccessPath W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus

This is def the correct workpaths etc?

Stan
I think the path for office 2000 would be:
AccessPath="C:\Program Files\Microsoft Office\OFFICE09\MSACCESS.EXE"
its giving the same file not found error on any version I try.. 11 and 9 at the moment..
Jaffer,
    I'm not real familiar with using Shell, but shouldn't it be:

Shell AccessPath & " W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus
Sorry for all this trouble guys, I thought a shortcut might be a good idea, but it seems IT IS NOT,
Lets stick to old vanilla (my favorate) ;o)

select case GetVersion()
 case "8.0" , "9.0", "10"
    Shell "C:\Program Files\Microsoft Office\OFFICE\MSACCESS.EXE  W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus

 case "11"
    Shell "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE  W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus

End If

DoCmd.Quit


By the way, the path and the Directory Names are only Examples of how to use the Selecr case,
you should put the proper path though.

jaffer
will_scarlet7

You might be right,
Shell AccessPath & " W:\Work\PGCallLog\PGMsg.mdb /WRKGRP W:\Work\PGCallLog\PGCallLog.mdw", vbMaximizedFocus
might work, but didn't try it.

jaffer
Looks like will_'s idea worked fine!

Thanks guys!
Glad to help.

God bless!
Hey will, Stan

I would like to thanks both of you for this and
"Remember Me Login Solution" thread,

I subscribed in that question, and boy I loved it.

jaffer
That's quite a compliment Jaffer. Thank you!
I agree with will and jaffer -

thanks to you both for the solutions - time time you guys have saved me and knowledge I have acquired as a result it unbelievable.

I don't know what developers did before EE :)

Stan
Hi Guys

I would like a add one more feature to this database relating to the above coding. To be fair, I have posted it as a new question so I can award more points!

I am looking for a way to modify Candace_Tripp's shortcut modules to allow the workgroup file options to be added.

The new question is located at:

https://www.experts-exchange.com/questions/21108932/DATABASE-SHORTCUT-Creating-a-Shortcut-for-a-Workgroup-File-Database-Automatically.html
(DATABASE SHORTCUT: Creating a Shortcut for a Workgroup File Database Automatically)

If you have any ideas, I would appreciate it!

Thx Again Stan