Re: Save User Information
- From: "Metra" <no@xxxxxxxxxxx>
- Date: Sat, 3 Dec 2005 10:15:30 -0600
Let me see if I understand your process -- you have a table of users, each
of which is assigned a unique identifier... you're not using a database
secured with a non-System MDW or an ADP which is using integrated
security...
If that's the case, probably the easiest thing is to have a database
property, perhaps called "myUserID", populated it when she logs on, and
empty when she logs off.
Below are two functions you can use to do this...Add them to a standard
module (If you don't have a reference to DAO, you'll need to add one):
To use:
call the SetCustomProperty function when she logs in.
Example: SetCustomProperty("myUserID",dbtext, cStr(UserID))
Whenever you want to get the number, call GetCustomProperty. You can use it
in queries or where-ever.
Example: GetCustomProperty("myUserID").
When you shut the application down, call the SetCustomProperty again,
setting the value to some invalid string, like a single space,
"N/A","LoggedOff", whatever.
'-----------Start Code Block-----------
Function SetCustomProperty(strPropName As String, intPropType _
As Integer, strPropValue As String) As Integer
Dim dbs As Database, cnt As Container
Dim doc As Document, prp As Property
Const conPropertyNotFound = 3270 ' Property not found error.
Set dbs = CurrentDb ' Define Database object.
Set cnt = dbs.Containers!Databases ' Define Container object.
Set doc = cnt.Documents!UserDefined ' Define Document object.
On Error GoTo SetCustom_Err
doc.Properties.Refresh
' Set custom property name. If error occurs here it means
' property doesn't exist and needs to be created and appended
' to Properties collection of Document object.
If strPropName = "" Then GoTo SetCustom_Bye Else
Set prp = doc.Properties(strPropName)
prp = strPropValue ' Set custom property value.
SetCustomProperty = True
SetCustom_Bye:
Exit Function
SetCustom_Err:
If Err = conPropertyNotFound Then
Set prp = doc.CreateProperty(strPropName, intPropType, strPropValue)
doc.Properties.Append prp ' Append to collection.
Resume Next
Else ' Unknown error.
SetCustomProperty = False
Resume SetCustom_Bye
End If
End Function
Function GetCustomProperty(strPropName As String) As String
Dim dbs As Database, cnt As Container
Dim doc As Document, prp As Property
' Property not found error.
Const conPropertyNotFound = 3270
On Error GoTo GetCustomProperty_Err
Set dbs = CurrentDb
Set cnt = dbs.Containers!Databases
Set doc = cnt.Documents!UserDefined
doc.Properties.Refresh
GetCustomProperty = doc.Properties(strPropName)
GetCustomProperty_Bye:
Exit Function
GetCustomProperty_Err:
If Err = conPropertyNotFound Then
Set prp = doc.CreateProperty(strPropName, dbtext, "None")
' Append to collection.
doc.Properties.Append prp
Resume
Else
' Unknown error.
GetCustomProperty = ""
Resume GetCustomProperty_Bye
End If
End Function
'-----------End Code Block-----------
"Russ via AccessMonster.com" <u12613@uwe> wrote in message
news:5849018688720@xxxxxx
> What I need to do is have a log in form that I can store and use the user
ID
> number of the person logged in.
> Example
> When Jane (ID#3) logs in it will store that Jane (ID#3) logged in at 7:30
AM
> into a table, then what ever form she opened it would automatically use
her
> user ID number until she logged out. We do not want to have the user keep
> selecting / entering their name on the form, want it to be automatic. Home
I
> am explaining this well enough??
>
> Thanks in advance!
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200512/1
.
- Follow-Ups:
- Re: Save User Information
- From: Russ via AccessMonster.com
- Re: Save User Information
- References:
- Save User Information
- From: Russ via AccessMonster.com
- Save User Information
- Prev by Date: Save User Information
- Next by Date: RE: Using a single Query as RowSource for many Combos - funny beha
- Previous by thread: Save User Information
- Next by thread: Re: Save User Information
- Index(es):
Relevant Pages
|