Re: Save User Information



Wow, thanks I will give it a try!

Metra wrote:
>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-----------
>
>> 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.
>[quoted text clipped - 6 lines]
>>
>> Thanks in advance!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200512/1
.



Relevant Pages

  • Re: Save User Information
    ... Function SetCustomProperty(strPropName As String, intPropType _ ... Dim doc As Document, prp As Property ... Set cnt = dbs.Containers!Databases ' Define Container object. ... Set doc = cnt.Documents!UserDefined ' Define Document object. ...
    (microsoft.public.access.modulesdaovba)
  • Re: AutoNew or AttachAs "name??" to create file name from data
    ... Dim Doc As Document ... Dim DocPathName As String ... can be deleted when the kill statement is executed. ...
    (microsoft.public.word.vba.general)
  • Access doc from web
    ... the first thing I tried was putting in the entire URL as a string ... doesn't seem to like the 'http://' reference. ... I also tried referencing the document object that I already opened. ... 'doc1.FullName', it still throws the same error saying, "The document name or ...
    (microsoft.public.scripting.vbscript)
  • Re: Reading in a textfile?
    ... Then use something like this to validate users ... private function IsValid(userName as string, userPin as string) ... Dim doc as XmlDocument ...
    (microsoft.public.dotnet.languages.vb)
  • Re: JDOM and &qout;
    ... >> i need to create document object and than transform it to string, ... SomeObject so = new SomeObject; ... //now i make Document object ... String output = new String; ...
    (comp.lang.java)