Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save user preferences?

Status
Not open for further replies.

asp3232

Technical User
Jun 25, 2002
27
0
0
US
Hi,

I've got a DB that multiple people access, and would like to have a flexible way for them to have a query that they can easily input the parameters for (such as looking for their own name in the contact information, etc).

I know I can do this directly in the query, having it prompt them for the info, but I'd like to set up a form where they can type in the info they'd like to filter on.

It seems the above should be pretty straightforward to do, but I'd like to be able to save the last set of parameters so that when the same user comes back to the form, they don't have to type everything in again.

I'd like to have the settings/options saved to the local machine, since we're currently only using filesystem security to control database access (a whole 'nother story...), and so all users look the same to the DB.

Basically I'm looking for the equivalent of a "Cookie" used by a web browser...

any ideas?

thanks!

asp
 
Hmm,

Have you experimented with using the user's windows logon to detect who's in the db (you can get it without any user input)? You could set up a table where the user's last set of parameters get written to a record with the user's logon upon exiting the db (each user could have 1 record that gets over-written every time, or you could do a last 3 system, etc). When the db opens, you could get the logon directly from the system, query on it, then have the parameters auto-appear...or something like that

Is this anything close to what you were asking?

Good lucj in any case,
CJ
 
Hi

You could save the information in the registry, which makes it PC specific, you obviously need the userId.

If you are using Access security, you can USe CurrentUser() to get this, if not there is VBA code around to get the current Network Log in Id, (for Windows).

Rather than store the information in the registry, I would opt to put it in a table, if you are operating a FrontEnd/Backend setup (if not, it is a good idea to do so), then you can have the table 'local' or shared by putting it in the FE (local), or the BE (Shared), once again you need to include the user Id to allow for personal settings, and obtain it as explained above.

I have code to get Network Log if you need it.

Hope this helps.
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Thanks for the reminder -- I had forgotten about being able to get the login ID without using access security -- that's almost certainly the best way to do it, and I'll put the table in the back-end db.

Could you please post the code/other ideas for how to get the login ID? I'd really appreciate it.

Thanks for your help, Ken and CJ!

asp
 
The easiest way I know is:
Environ("USERNAME")
It give you the name as string, no scary security details...

Good luck,
CJ
 
Hi

To get user Network login id:

Option Compare Database
Option Explicit

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = &quot;&quot;
End If
End Function

I have tried above with WinNT, Win2K, Win98, WinXP and it works OK, anything else I cannot say, but I would be interested to hear from you if you extent the range of know OS where it works.

Good luck. Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top