Home All Groups Group Topic Archive Search About

Understandable documentation regarding Access DBA security

Author
26 May 2009 10:40 AM
Peter
Hi all, and thanks for this great place...! Were can i find a easy to read,
step by step documentation on how i set up the database security. I am now
more or less ready with my application and i intend to splitt it into a
front- and back end. 10 users. The back end resides on a shared drive. All i
need is for each user to log in with his/her username and PW. This is
important since i also have a module that "picks up" the username and
populates the fOSUserName controll...

Thanks!

Author
26 May 2009 12:22 PM
Douglas J. Steele
Unfortunately, Access User-Level Security isn't a simple proposition.

The most comprehensive document is
http://support.microsoft.com/support/access/content/secfaq.asp Make sure you
read it thoroughly several times before starting, work on a copy of your
database (just in case!) and make sure you don't leave out any steps.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:03076C80-3A94-470E-B79F-438454AB06EC@microsoft.com...
> Hi all, and thanks for this great place...! Were can i find a easy to
> read,
> step by step documentation on how i set up the database security. I am now
> more or less ready with my application and i intend to splitt it into a
> front- and back end. 10 users. The back end resides on a shared drive. All
> i
> need is for each user to log in with his/her username and PW. This is
> important since i also have a module that "picks up" the username and
> populates the fOSUserName controll...
>
> Thanks!
Are all your drivers up to date? click for free checkup

Author
27 May 2009 11:50 AM
Peter
Hi again...this documentation refers to Access 2.0-2000..i use 2003..is it
valid for me?

Thanks!

Show quoteHide quote
"Douglas J. Steele" wrote:

> Unfortunately, Access User-Level Security isn't a simple proposition.
>
> The most comprehensive document is
> http://support.microsoft.com/support/access/content/secfaq.asp Make sure you
> read it thoroughly several times before starting, work on a copy of your
> database (just in case!) and make sure you don't leave out any steps.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:03076C80-3A94-470E-B79F-438454AB06EC@microsoft.com...
> > Hi all, and thanks for this great place...! Were can i find a easy to
> > read,
> > step by step documentation on how i set up the database security. I am now
> > more or less ready with my application and i intend to splitt it into a
> > front- and back end. 10 users. The back end resides on a shared drive. All
> > i
> > need is for each user to log in with his/her username and PW. This is
> > important since i also have a module that "picks up" the username and
> > populates the fOSUserName controll...
> >
> > Thanks!
>
>
>
Author
27 May 2009 12:25 PM
Douglas J. Steele
Yes. Nothing changed with respect to ULS in Access 2002 or Access 2003 or
MDB files in Access 2007.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:72201A5F-964A-4354-8F9B-4D8EF22C686C@microsoft.com...
> Hi again...this documentation refers to Access 2.0-2000..i use 2003..is it
> valid for me?
>
> Thanks!
>
> "Douglas J. Steele" wrote:
>
>> Unfortunately, Access User-Level Security isn't a simple proposition.
>>
>> The most comprehensive document is
>> http://support.microsoft.com/support/access/content/secfaq.asp Make sure
>> you
>> read it thoroughly several times before starting, work on a copy of your
>> database (just in case!) and make sure you don't leave out any steps.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> news:03076C80-3A94-470E-B79F-438454AB06EC@microsoft.com...
>> > Hi all, and thanks for this great place...! Were can i find a easy to
>> > read,
>> > step by step documentation on how i set up the database security. I am
>> > now
>> > more or less ready with my application and i intend to splitt it into a
>> > front- and back end. 10 users. The back end resides on a shared drive.
>> > All
>> > i
>> > need is for each user to log in with his/her username and PW. This is
>> > important since i also have a module that "picks up" the username and
>> > populates the fOSUserName controll...
>> >
>> > Thanks!
>>
>>
>>
Author
28 May 2009 6:29 AM
Tony Toews [MVP]
Peter <Pe***@discussions.microsoft.com> wrote:

>Hi all, and thanks for this great place...! Were can i find a easy to read,
>step by step documentation on how i set up the database security. I am now
>more or less ready with my application and i intend to splitt it into a
>front- and back end. 10 users. The back end resides on a shared drive. All i
>need is for each user to log in with his/her username and PW. This is
>important since i also have a module that "picks up" the username and
>populates the fOSUserName controll...

Why not just use the network user id? API: Get Login name
http://www.mvps.org/access/api/api0008.htm

Do you really need to secure the objects within the MDB file, either
FE or BE?

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
Author
28 May 2009 12:30 PM
Peter
Hi Tony...:-)..here is what i need..

"/Hi again...i have an issue with "picking up" the username of the Windows
system.

http://www.mvps.org/access/api/api0008.htm. I copied the whole code and i
pasted it in a module (Module1) this is how it looks:

Option Compare Database

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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 = vbNullString
    End If
End Function

I followed the conversation Subject: Re: Returning current user from SQLServer

And the bottom line is, this is what i need. I want the username to be
posted on my opening form (whiwch is always open when the application runs)
in order to refer to it later. I have created a textbox, "Username". On the
opening event of my form i use DoCmd.Maximize...were do i put Me.txtUserName
= fOSUserName????

fOSUserName is part of my client table...whoever creates or modifies a
record will be populated here...

I appologize for my ignorance :-)




Show quoteHide quote
"Tony Toews [MVP]" wrote:

> Peter <Pe***@discussions.microsoft.com> wrote:
>
> >Hi all, and thanks for this great place...! Were can i find a easy to read,
> >step by step documentation on how i set up the database security. I am now
> >more or less ready with my application and i intend to splitt it into a
> >front- and back end. 10 users. The back end resides on a shared drive. All i
> >need is for each user to log in with his/her username and PW. This is
> >important since i also have a module that "picks up" the username and
> >populates the fOSUserName controll...
>
> Why not just use the network user id? API: Get Login name
> http://www.mvps.org/access/api/api0008.htm
>
> Do you really need to secure the objects within the MDB file, either
> FE or BE?
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> Granite Fleet Manager http://www.granitefleet.com/
>
Author
28 May 2009 12:45 PM
Douglas J. Steele
Is textbox txtUserName bound to a field in the form's recordsource (i.e.:
you can to save it to a table), or are you simply trying to display it?

If the latter (you're simply trying to display it), just set the text box's
ControlSource property to\

= fOSUserName()

(including the equal sign)

If the former, put your code in the form's Load event.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:176BE3DA-DE28-4879-845D-4341A2EB0BE4@microsoft.com...
> Hi Tony...:-)..here is what i need..
>
> "/Hi again...i have an issue with "picking up" the username of the Windows
> system.
>
> http://www.mvps.org/access/api/api0008.htm. I copied the whole code and i
> pasted it in a module (Module1) this is how it looks:
>
> Option Compare Database
>
> ' This code was originally written by Dev Ashish.
> ' It is not to be altered or distributed,
> ' except as part of an application.
> ' You are free to use it in any application,
> ' provided the copyright notice is left unchanged.
> '
> ' Code Courtesy of
> ' Dev Ashish
> '
> 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 = vbNullString
>    End If
> End Function
>
> I followed the conversation Subject: Re: Returning current user from
> SQLServer
>
> And the bottom line is, this is what i need. I want the username to be
> posted on my opening form (whiwch is always open when the application
> runs)
> in order to refer to it later. I have created a textbox, "Username". On
> the
> opening event of my form i use DoCmd.Maximize...were do i put
> Me.txtUserName
> = fOSUserName????
>
> fOSUserName is part of my client table...whoever creates or modifies a
> record will be populated here...
>
> I appologize for my ignorance :-)
>
>
>
>
> "Tony Toews [MVP]" wrote:
>
>> Peter <Pe***@discussions.microsoft.com> wrote:
>>
>> >Hi all, and thanks for this great place...! Were can i find a easy to
>> >read,
>> >step by step documentation on how i set up the database security. I am
>> >now
>> >more or less ready with my application and i intend to splitt it into a
>> >front- and back end. 10 users. The back end resides on a shared drive.
>> >All i
>> >need is for each user to log in with his/her username and PW. This is
>> >important since i also have a module that "picks up" the username and
>> >populates the fOSUserName controll...
>>
>> Why not just use the network user id? API: Get Login name
>> http://www.mvps.org/access/api/api0008.htm
>>
>> Do you really need to secure the objects within the MDB file, either
>> FE or BE?
>>
>> Tony
>> --
>> Tony Toews, Microsoft Access MVP
>> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> Granite Fleet Manager http://www.granitefleet.com/
>>
Author
29 May 2009 7:37 AM
Tony Toews [MVP]
Peter <Pe***@discussions.microsoft.com> wrote:

>And the bottom line is, this is what i need. I want the username to be
>posted on my opening form (whiwch is always open when the application runs)
>in order to refer to it later.

That's what I was wondering.  Rather than sending you way off into the
complex world of Access security.

And I see Douglas has replied.

>I appologize for my ignorance :-)

We don't mind ignorance because we like helping.   So continue to ask
away.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Granite Fleet Manager http://www.granitefleet.com/
Author
29 May 2009 8:48 AM
Peter
Ok Tony...i am using this

Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err

    ' Set bound controls to system date and time and current user name.
    Me.DateModified = Date
    Me.TimeModified = Time()
    Me.fOSUserName = fOSUserName()
BeforeUpdate_End:
    Exit Sub
BeforeUpdate_Err:
    MsgBox Err.Description, vbCritical & vbOKOnly, _
        "Error Number " & Err.Number & " Occurred"
    Resume BeforeUpdate_End
End Sub

The module to pick up the API code is in place...but the bound controll is
still not populated i use the above code on a Before Update event for the
Form..and the time and date functions....i beleive i am doing something very
wrong..

Show quoteHide quote
"Tony Toews [MVP]" wrote:

> Peter <Pe***@discussions.microsoft.com> wrote:
>
> >And the bottom line is, this is what i need. I want the username to be
> >posted on my opening form (whiwch is always open when the application runs)
> >in order to refer to it later.
>
> That's what I was wondering.  Rather than sending you way off into the
> complex world of Access security.
>
> And I see Douglas has replied.
>
> >I appologize for my ignorance :-)
>
> We don't mind ignorance because we like helping.   So continue to ask
> away.
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> Granite Fleet Manager http://www.granitefleet.com/
>
Author
29 May 2009 12:15 PM
Douglas J. Steele
Try using something other than fOSUserName as the name of the text box. The
ambiguity is probably confusing Access.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> Ok Tony...i am using this
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
>    On Error GoTo BeforeUpdate_Err
>
>    ' Set bound controls to system date and time and current user name.
>    Me.DateModified = Date
>    Me.TimeModified = Time()
>    Me.fOSUserName = fOSUserName()
> BeforeUpdate_End:
>    Exit Sub
> BeforeUpdate_Err:
>    MsgBox Err.Description, vbCritical & vbOKOnly, _
>        "Error Number " & Err.Number & " Occurred"
>    Resume BeforeUpdate_End
> End Sub
>
> The module to pick up the API code is in place...but the bound controll is
> still not populated i use the above code on a Before Update event for the
> Form..and the time and date functions....i beleive i am doing something
> very
> wrong..
>
> "Tony Toews [MVP]" wrote:
>
>> Peter <Pe***@discussions.microsoft.com> wrote:
>>
>> >And the bottom line is, this is what i need. I want the username to be
>> >posted on my opening form (whiwch is always open when the application
>> >runs)
>> >in order to refer to it later.
>>
>> That's what I was wondering.  Rather than sending you way off into the
>> complex world of Access security.
>>
>> And I see Douglas has replied.
>>
>> >I appologize for my ignorance :-)
>>
>> We don't mind ignorance because we like helping.   So continue to ask
>> away.
>>
>> Tony
>> --
>> Tony Toews, Microsoft Access MVP
>> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> Granite Fleet Manager http://www.granitefleet.com/
>>
Author
29 May 2009 2:34 PM
Peter
Hoping you are a person of great patiance...-:)..

Nope..if i use the below code..it does not update my bounded Operator text
field with the current user when i edit this specific record...

If i set the control source to = fOSUserName() it populates this text
field...but regardless if the record is editet or not..just by opening it...

I need to know whois the last person that edited the record...the time and
date functions well..displays the current date/time the record was
edited...after that i exit the record...thats ok

Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err

    ' Set bound controls to system date and time and current user name.
    Me.DateModified = Date
    Me.TimeModified = Time()
    Me.Operator = fOSUserName()
BeforeUpdate_End:
    Exit Sub
BeforeUpdate_Err:
    MsgBox Err.Description, vbCritical & vbOKOnly, _
        "Error Number " & Err.Number & " Occurred"
    Resume BeforeUpdat

Show quoteHide quote
"Douglas J. Steele" wrote:

> Try using something other than fOSUserName as the name of the text box. The
> ambiguity is probably confusing Access.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> > Ok Tony...i am using this
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >    On Error GoTo BeforeUpdate_Err
> >
> >    ' Set bound controls to system date and time and current user name.
> >    Me.DateModified = Date
> >    Me.TimeModified = Time()
> >    Me.fOSUserName = fOSUserName()
> > BeforeUpdate_End:
> >    Exit Sub
> > BeforeUpdate_Err:
> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >        "Error Number " & Err.Number & " Occurred"
> >    Resume BeforeUpdate_End
> > End Sub
> >
> > The module to pick up the API code is in place...but the bound controll is
> > still not populated i use the above code on a Before Update event for the
> > Form..and the time and date functions....i beleive i am doing something
> > very
> > wrong..
> >
> > "Tony Toews [MVP]" wrote:
> >
> >> Peter <Pe***@discussions.microsoft.com> wrote:
> >>
> >> >And the bottom line is, this is what i need. I want the username to be
> >> >posted on my opening form (whiwch is always open when the application
> >> >runs)
> >> >in order to refer to it later.
> >>
> >> That's what I was wondering.  Rather than sending you way off into the
> >> complex world of Access security.
> >>
> >> And I see Douglas has replied.
> >>
> >> >I appologize for my ignorance :-)
> >>
> >> We don't mind ignorance because we like helping.   So continue to ask
> >> away.
> >>
> >> Tony
> >> --
> >> Tony Toews, Microsoft Access MVP
> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> >> Granite Fleet Manager http://www.granitefleet.com/
> >>
>
>
>
Author
29 May 2009 3:03 PM
Douglas J. Steele
So you're saying that the DateModified and TimeModified fields are being
updated (why are you storing them in separate fields, btw? You should have a
single field and populate it using the Now function), but that Operator
isn't? That makes no sense.

For debugging purposes, try the following:

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo BeforeUpdate_Err

  MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
    "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
    "fOSUserName = " & fOSUserName()

' Set bound controls to system date and time and current user name.
  Me.DateModified = Date
  Me.TimeModified = Time()
  Me.Operator = fOSUserName()

  MsgBox "After: Operator " & Me.Operator & vbCrLf & _
    "(" & Me.DateModified & " " & Me.TimeModified & ")"

BeforeUpdate_End:
  Exit Sub

BeforeUpdate_Err:
  MsgBox Err.Description, vbCritical & vbOKOnly, _
    "Error Number " & Err.Number & " Occurred"
  Resume BeforeUpdate_End

End Sub



--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> Hoping you are a person of great patiance...-:)..
>
> Nope..if i use the below code..it does not update my bounded Operator text
> field with the current user when i edit this specific record...
>
> If i set the control source to = fOSUserName() it populates this text
> field...but regardless if the record is editet or not..just by opening
> it...
>
> I need to know whois the last person that edited the record...the time and
> date functions well..displays the current date/time the record was
> edited...after that i exit the record...thats ok
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
>    On Error GoTo BeforeUpdate_Err
>
>    ' Set bound controls to system date and time and current user name.
>    Me.DateModified = Date
>    Me.TimeModified = Time()
>    Me.Operator = fOSUserName()
> BeforeUpdate_End:
>    Exit Sub
> BeforeUpdate_Err:
>    MsgBox Err.Description, vbCritical & vbOKOnly, _
>        "Error Number " & Err.Number & " Occurred"
>    Resume BeforeUpdat
>
> "Douglas J. Steele" wrote:
>
>> Try using something other than fOSUserName as the name of the text box.
>> The
>> ambiguity is probably confusing Access.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
>> > Ok Tony...i am using this
>> >
>> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >    On Error GoTo BeforeUpdate_Err
>> >
>> >    ' Set bound controls to system date and time and current user name.
>> >    Me.DateModified = Date
>> >    Me.TimeModified = Time()
>> >    Me.fOSUserName = fOSUserName()
>> > BeforeUpdate_End:
>> >    Exit Sub
>> > BeforeUpdate_Err:
>> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >        "Error Number " & Err.Number & " Occurred"
>> >    Resume BeforeUpdate_End
>> > End Sub
>> >
>> > The module to pick up the API code is in place...but the bound controll
>> > is
>> > still not populated i use the above code on a Before Update event for
>> > the
>> > Form..and the time and date functions....i beleive i am doing something
>> > very
>> > wrong..
>> >
>> > "Tony Toews [MVP]" wrote:
>> >
>> >> Peter <Pe***@discussions.microsoft.com> wrote:
>> >>
>> >> >And the bottom line is, this is what i need. I want the username to
>> >> >be
>> >> >posted on my opening form (whiwch is always open when the application
>> >> >runs)
>> >> >in order to refer to it later.
>> >>
>> >> That's what I was wondering.  Rather than sending you way off into the
>> >> complex world of Access security.
>> >>
>> >> And I see Douglas has replied.
>> >>
>> >> >I appologize for my ignorance :-)
>> >>
>> >> We don't mind ignorance because we like helping.   So continue to ask
>> >> away.
>> >>
>> >> Tony
>> >> --
>> >> Tony Toews, Microsoft Access MVP
>> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> >> Granite Fleet Manager http://www.granitefleet.com/
>> >>
>>
>>
>>
Author
29 May 2009 3:56 PM
Peter
When i replace my code with yours i receive two small popups after exiting
the record..i did some edits

1. Before: Operator (29/05/2009 17:51:48) fOSUername =
2. After: Operator (29/05/2009 17:54:16)

Show quoteHide quote
"Douglas J. Steele" wrote:

> So you're saying that the DateModified and TimeModified fields are being
> updated (why are you storing them in separate fields, btw? You should have a
> single field and populate it using the Now function), but that Operator
> isn't? That makes no sense.
>
> For debugging purposes, try the following:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> On Error GoTo BeforeUpdate_Err
>
>   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
>     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
>     "fOSUserName = " & fOSUserName()
>
> ' Set bound controls to system date and time and current user name.
>   Me.DateModified = Date
>   Me.TimeModified = Time()
>   Me.Operator = fOSUserName()
>
>   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
>     "(" & Me.DateModified & " " & Me.TimeModified & ")"
>
> BeforeUpdate_End:
>   Exit Sub
>
> BeforeUpdate_Err:
>   MsgBox Err.Description, vbCritical & vbOKOnly, _
>     "Error Number " & Err.Number & " Occurred"
>   Resume BeforeUpdate_End
>
> End Sub
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> > Hoping you are a person of great patiance...-:)..
> >
> > Nope..if i use the below code..it does not update my bounded Operator text
> > field with the current user when i edit this specific record...
> >
> > If i set the control source to = fOSUserName() it populates this text
> > field...but regardless if the record is editet or not..just by opening
> > it...
> >
> > I need to know whois the last person that edited the record...the time and
> > date functions well..displays the current date/time the record was
> > edited...after that i exit the record...thats ok
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >    On Error GoTo BeforeUpdate_Err
> >
> >    ' Set bound controls to system date and time and current user name.
> >    Me.DateModified = Date
> >    Me.TimeModified = Time()
> >    Me.Operator = fOSUserName()
> > BeforeUpdate_End:
> >    Exit Sub
> > BeforeUpdate_Err:
> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >        "Error Number " & Err.Number & " Occurred"
> >    Resume BeforeUpdat
> >
> > "Douglas J. Steele" wrote:
> >
> >> Try using something other than fOSUserName as the name of the text box.
> >> The
> >> ambiguity is probably confusing Access.
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no private e-mails, please)
> >>
> >>
> >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> >> > Ok Tony...i am using this
> >> >
> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> >    On Error GoTo BeforeUpdate_Err
> >> >
> >> >    ' Set bound controls to system date and time and current user name.
> >> >    Me.DateModified = Date
> >> >    Me.TimeModified = Time()
> >> >    Me.fOSUserName = fOSUserName()
> >> > BeforeUpdate_End:
> >> >    Exit Sub
> >> > BeforeUpdate_Err:
> >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> >        "Error Number " & Err.Number & " Occurred"
> >> >    Resume BeforeUpdate_End
> >> > End Sub
> >> >
> >> > The module to pick up the API code is in place...but the bound controll
> >> > is
> >> > still not populated i use the above code on a Before Update event for
> >> > the
> >> > Form..and the time and date functions....i beleive i am doing something
> >> > very
> >> > wrong..
> >> >
> >> > "Tony Toews [MVP]" wrote:
> >> >
> >> >> Peter <Pe***@discussions.microsoft.com> wrote:
> >> >>
> >> >> >And the bottom line is, this is what i need. I want the username to
> >> >> >be
> >> >> >posted on my opening form (whiwch is always open when the application
> >> >> >runs)
> >> >> >in order to refer to it later.
> >> >>
> >> >> That's what I was wondering.  Rather than sending you way off into the
> >> >> complex world of Access security.
> >> >>
> >> >> And I see Douglas has replied.
> >> >>
> >> >> >I appologize for my ignorance :-)
> >> >>
> >> >> We don't mind ignorance because we like helping.   So continue to ask
> >> >> away.
> >> >>
> >> >> Tony
> >> >> --
> >> >> Tony Toews, Microsoft Access MVP
> >> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> >> >> Granite Fleet Manager http://www.granitefleet.com/
> >> >>
> >>
> >>
> >>
>
>
>
Author
29 May 2009 10:00 PM
Peter
...and the reson for the seperate Time Date fieled is this idea that i want to
caclulate the elapsed tome between time created and time modified in the
future..just an experiment...

Show quoteHide quote
"Peter" wrote:

> When i replace my code with yours i receive two small popups after exiting
> the record..i did some edits
>
> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> 2. After: Operator (29/05/2009 17:54:16)
>
> "Douglas J. Steele" wrote:
>
> > So you're saying that the DateModified and TimeModified fields are being
> > updated (why are you storing them in separate fields, btw? You should have a
> > single field and populate it using the Now function), but that Operator
> > isn't? That makes no sense.
> >
> > For debugging purposes, try the following:
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > On Error GoTo BeforeUpdate_Err
> >
> >   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
> >     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
> >     "fOSUserName = " & fOSUserName()
> >
> > ' Set bound controls to system date and time and current user name.
> >   Me.DateModified = Date
> >   Me.TimeModified = Time()
> >   Me.Operator = fOSUserName()
> >
> >   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
> >     "(" & Me.DateModified & " " & Me.TimeModified & ")"
> >
> > BeforeUpdate_End:
> >   Exit Sub
> >
> > BeforeUpdate_Err:
> >   MsgBox Err.Description, vbCritical & vbOKOnly, _
> >     "Error Number " & Err.Number & " Occurred"
> >   Resume BeforeUpdate_End
> >
> > End Sub
> >
> >
> >
> > --
> > Doug Steele, Microsoft Access MVP
> > http://I.Am/DougSteele
> > (no private e-mails, please)
> >
> >
> > "Peter" <Pe***@discussions.microsoft.com> wrote in message
> > news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> > > Hoping you are a person of great patiance...-:)..
> > >
> > > Nope..if i use the below code..it does not update my bounded Operator text
> > > field with the current user when i edit this specific record...
> > >
> > > If i set the control source to = fOSUserName() it populates this text
> > > field...but regardless if the record is editet or not..just by opening
> > > it...
> > >
> > > I need to know whois the last person that edited the record...the time and
> > > date functions well..displays the current date/time the record was
> > > edited...after that i exit the record...thats ok
> > >
> > > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > >    On Error GoTo BeforeUpdate_Err
> > >
> > >    ' Set bound controls to system date and time and current user name.
> > >    Me.DateModified = Date
> > >    Me.TimeModified = Time()
> > >    Me.Operator = fOSUserName()
> > > BeforeUpdate_End:
> > >    Exit Sub
> > > BeforeUpdate_Err:
> > >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> > >        "Error Number " & Err.Number & " Occurred"
> > >    Resume BeforeUpdat
> > >
> > > "Douglas J. Steele" wrote:
> > >
> > >> Try using something other than fOSUserName as the name of the text box.
> > >> The
> > >> ambiguity is probably confusing Access.
> > >>
> > >> --
> > >> Doug Steele, Microsoft Access MVP
> > >> http://I.Am/DougSteele
> > >> (no private e-mails, please)
> > >>
> > >>
> > >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> > >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> > >> > Ok Tony...i am using this
> > >> >
> > >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> > >> >    On Error GoTo BeforeUpdate_Err
> > >> >
> > >> >    ' Set bound controls to system date and time and current user name.
> > >> >    Me.DateModified = Date
> > >> >    Me.TimeModified = Time()
> > >> >    Me.fOSUserName = fOSUserName()
> > >> > BeforeUpdate_End:
> > >> >    Exit Sub
> > >> > BeforeUpdate_Err:
> > >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> > >> >        "Error Number " & Err.Number & " Occurred"
> > >> >    Resume BeforeUpdate_End
> > >> > End Sub
> > >> >
> > >> > The module to pick up the API code is in place...but the bound controll
> > >> > is
> > >> > still not populated i use the above code on a Before Update event for
> > >> > the
> > >> > Form..and the time and date functions....i beleive i am doing something
> > >> > very
> > >> > wrong..
> > >> >
> > >> > "Tony Toews [MVP]" wrote:
> > >> >
> > >> >> Peter <Pe***@discussions.microsoft.com> wrote:
> > >> >>
> > >> >> >And the bottom line is, this is what i need. I want the username to
> > >> >> >be
> > >> >> >posted on my opening form (whiwch is always open when the application
> > >> >> >runs)
> > >> >> >in order to refer to it later.
> > >> >>
> > >> >> That's what I was wondering.  Rather than sending you way off into the
> > >> >> complex world of Access security.
> > >> >>
> > >> >> And I see Douglas has replied.
> > >> >>
> > >> >> >I appologize for my ignorance :-)
> > >> >>
> > >> >> We don't mind ignorance because we like helping.   So continue to ask
> > >> >> away.
> > >> >>
> > >> >> Tony
> > >> >> --
> > >> >> Tony Toews, Microsoft Access MVP
> > >> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> > >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> > >> >> Granite Fleet Manager http://www.granitefleet.com/
> > >> >>
> > >>
> > >>
> > >>
> >
> >
> >
Author
30 May 2009 12:18 PM
Douglas J. Steele
DateDiff works just as well with Date/Time as with Time only.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:1F921D75-7B00-4730-886B-675A50E1D343@microsoft.com...
> ..and the reson for the seperate Time Date fieled is this idea that i want
> to
> caclulate the elapsed tome between time created and time modified in the
> future..just an experiment...
>
> "Peter" wrote:
>
>> When i replace my code with yours i receive two small popups after
>> exiting
>> the record..i did some edits
>>
>> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
>> 2. After: Operator (29/05/2009 17:54:16)
>>
>> "Douglas J. Steele" wrote:
>>
>> > So you're saying that the DateModified and TimeModified fields are
>> > being
>> > updated (why are you storing them in separate fields, btw? You should
>> > have a
>> > single field and populate it using the Now function), but that Operator
>> > isn't? That makes no sense.
>> >
>> > For debugging purposes, try the following:
>> >
>> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> > On Error GoTo BeforeUpdate_Err
>> >
>> >   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
>> >     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
>> >     "fOSUserName = " & fOSUserName()
>> >
>> > ' Set bound controls to system date and time and current user name.
>> >   Me.DateModified = Date
>> >   Me.TimeModified = Time()
>> >   Me.Operator = fOSUserName()
>> >
>> >   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
>> >     "(" & Me.DateModified & " " & Me.TimeModified & ")"
>> >
>> > BeforeUpdate_End:
>> >   Exit Sub
>> >
>> > BeforeUpdate_Err:
>> >   MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >     "Error Number " & Err.Number & " Occurred"
>> >   Resume BeforeUpdate_End
>> >
>> > End Sub
>> >
>> >
>> >
>> > --
>> > Doug Steele, Microsoft Access MVP
>> > http://I.Am/DougSteele
>> > (no private e-mails, please)
>> >
>> >
>> > "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> > news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
>> > > Hoping you are a person of great patiance...-:)..
>> > >
>> > > Nope..if i use the below code..it does not update my bounded Operator
>> > > text
>> > > field with the current user when i edit this specific record...
>> > >
>> > > If i set the control source to = fOSUserName() it populates this text
>> > > field...but regardless if the record is editet or not..just by
>> > > opening
>> > > it...
>> > >
>> > > I need to know whois the last person that edited the record...the
>> > > time and
>> > > date functions well..displays the current date/time the record was
>> > > edited...after that i exit the record...thats ok
>> > >
>> > > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> > >    On Error GoTo BeforeUpdate_Err
>> > >
>> > >    ' Set bound controls to system date and time and current user
>> > > name.
>> > >    Me.DateModified = Date
>> > >    Me.TimeModified = Time()
>> > >    Me.Operator = fOSUserName()
>> > > BeforeUpdate_End:
>> > >    Exit Sub
>> > > BeforeUpdate_Err:
>> > >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> > >        "Error Number " & Err.Number & " Occurred"
>> > >    Resume BeforeUpdat
>> > >
>> > > "Douglas J. Steele" wrote:
>> > >
>> > >> Try using something other than fOSUserName as the name of the text
>> > >> box.
>> > >> The
>> > >> ambiguity is probably confusing Access.
>> > >>
>> > >> --
>> > >> Doug Steele, Microsoft Access MVP
>> > >> http://I.Am/DougSteele
>> > >> (no private e-mails, please)
>> > >>
>> > >>
>> > >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> > >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
>> > >> > Ok Tony...i am using this
>> > >> >
>> > >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> > >> >    On Error GoTo BeforeUpdate_Err
>> > >> >
>> > >> >    ' Set bound controls to system date and time and current user
>> > >> > name.
>> > >> >    Me.DateModified = Date
>> > >> >    Me.TimeModified = Time()
>> > >> >    Me.fOSUserName = fOSUserName()
>> > >> > BeforeUpdate_End:
>> > >> >    Exit Sub
>> > >> > BeforeUpdate_Err:
>> > >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> > >> >        "Error Number " & Err.Number & " Occurred"
>> > >> >    Resume BeforeUpdate_End
>> > >> > End Sub
>> > >> >
>> > >> > The module to pick up the API code is in place...but the bound
>> > >> > controll
>> > >> > is
>> > >> > still not populated i use the above code on a Before Update event
>> > >> > for
>> > >> > the
>> > >> > Form..and the time and date functions....i beleive i am doing
>> > >> > something
>> > >> > very
>> > >> > wrong..
>> > >> >
>> > >> > "Tony Toews [MVP]" wrote:
>> > >> >
>> > >> >> Peter <Pe***@discussions.microsoft.com> wrote:
>> > >> >>
>> > >> >> >And the bottom line is, this is what i need. I want the username
>> > >> >> >to
>> > >> >> >be
>> > >> >> >posted on my opening form (whiwch is always open when the
>> > >> >> >application
>> > >> >> >runs)
>> > >> >> >in order to refer to it later.
>> > >> >>
>> > >> >> That's what I was wondering.  Rather than sending you way off
>> > >> >> into the
>> > >> >> complex world of Access security.
>> > >> >>
>> > >> >> And I see Douglas has replied.
>> > >> >>
>> > >> >> >I appologize for my ignorance :-)
>> > >> >>
>> > >> >> We don't mind ignorance because we like helping.   So continue to
>> > >> >> ask
>> > >> >> away.
>> > >> >>
>> > >> >> Tony
>> > >> >> --
>> > >> >> Tony Toews, Microsoft Access MVP
>> > >> >> Tony's Main MS Access pages -
>> > >> >> http://www.granite.ab.ca/accsmstr.htm
>> > >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> > >> >> Granite Fleet Manager http://www.granitefleet.com/
>> > >> >>
>> > >>
>> > >>
>> > >>
>> >
>> >
>> >
Author
30 May 2009 5:48 PM
Peter
Yes Douglas. Unbound textbox with controll source =fOSUserName() works just
fine..perhaps i should just set an invisible textbox with =fOSUserName() and
refer to that the following way:

Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err

    ' Set bound controls to system date and time and current user name.
    Me.DateModified = Date
    Me.TimeModified = Time()
    Me.Username = Forms!Spider_reports.UserName

The date
BeforeUpdate_End:
    Exit Sub
BeforeUpdate_Err:
    MsgBox Err.Description, vbCritical & vbOKOnly, _
        "Error Number " & Err.Number & " Occurred"
    Resume BeforeUpdate_End
End Sub


I will deffently use the DateDiff in order to be able to calculate the time
spent on a specific record...Thanks..well..step by step...day by day..:-)

Show quoteHide quote
"Douglas J. Steele" wrote:

> DateDiff works just as well with Date/Time as with Time only.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:1F921D75-7B00-4730-886B-675A50E1D343@microsoft.com...
> > ..and the reson for the seperate Time Date fieled is this idea that i want
> > to
> > caclulate the elapsed tome between time created and time modified in the
> > future..just an experiment...
> >
> > "Peter" wrote:
> >
> >> When i replace my code with yours i receive two small popups after
> >> exiting
> >> the record..i did some edits
> >>
> >> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> >> 2. After: Operator (29/05/2009 17:54:16)
> >>
> >> "Douglas J. Steele" wrote:
> >>
> >> > So you're saying that the DateModified and TimeModified fields are
> >> > being
> >> > updated (why are you storing them in separate fields, btw? You should
> >> > have a
> >> > single field and populate it using the Now function), but that Operator
> >> > isn't? That makes no sense.
> >> >
> >> > For debugging purposes, try the following:
> >> >
> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > On Error GoTo BeforeUpdate_Err
> >> >
> >> >   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
> >> >     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
> >> >     "fOSUserName = " & fOSUserName()
> >> >
> >> > ' Set bound controls to system date and time and current user name.
> >> >   Me.DateModified = Date
> >> >   Me.TimeModified = Time()
> >> >   Me.Operator = fOSUserName()
> >> >
> >> >   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
> >> >     "(" & Me.DateModified & " " & Me.TimeModified & ")"
> >> >
> >> > BeforeUpdate_End:
> >> >   Exit Sub
> >> >
> >> > BeforeUpdate_Err:
> >> >   MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> >     "Error Number " & Err.Number & " Occurred"
> >> >   Resume BeforeUpdate_End
> >> >
> >> > End Sub
> >> >
> >> >
> >> >
> >> > --
> >> > Doug Steele, Microsoft Access MVP
> >> > http://I.Am/DougSteele
> >> > (no private e-mails, please)
> >> >
> >> >
> >> > "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> > news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> >> > > Hoping you are a person of great patiance...-:)..
> >> > >
> >> > > Nope..if i use the below code..it does not update my bounded Operator
> >> > > text
> >> > > field with the current user when i edit this specific record...
> >> > >
> >> > > If i set the control source to = fOSUserName() it populates this text
> >> > > field...but regardless if the record is editet or not..just by
> >> > > opening
> >> > > it...
> >> > >
> >> > > I need to know whois the last person that edited the record...the
> >> > > time and
> >> > > date functions well..displays the current date/time the record was
> >> > > edited...after that i exit the record...thats ok
> >> > >
> >> > > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > >    On Error GoTo BeforeUpdate_Err
> >> > >
> >> > >    ' Set bound controls to system date and time and current user
> >> > > name.
> >> > >    Me.DateModified = Date
> >> > >    Me.TimeModified = Time()
> >> > >    Me.Operator = fOSUserName()
> >> > > BeforeUpdate_End:
> >> > >    Exit Sub
> >> > > BeforeUpdate_Err:
> >> > >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> > >        "Error Number " & Err.Number & " Occurred"
> >> > >    Resume BeforeUpdat
> >> > >
> >> > > "Douglas J. Steele" wrote:
> >> > >
> >> > >> Try using something other than fOSUserName as the name of the text
> >> > >> box.
> >> > >> The
> >> > >> ambiguity is probably confusing Access.
> >> > >>
> >> > >> --
> >> > >> Doug Steele, Microsoft Access MVP
> >> > >> http://I.Am/DougSteele
> >> > >> (no private e-mails, please)
> >> > >>
> >> > >>
> >> > >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> > >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> >> > >> > Ok Tony...i am using this
> >> > >> >
> >> > >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > >> >    On Error GoTo BeforeUpdate_Err
> >> > >> >
> >> > >> >    ' Set bound controls to system date and time and current user
> >> > >> > name.
> >> > >> >    Me.DateModified = Date
> >> > >> >    Me.TimeModified = Time()
> >> > >> >    Me.fOSUserName = fOSUserName()
> >> > >> > BeforeUpdate_End:
> >> > >> >    Exit Sub
> >> > >> > BeforeUpdate_Err:
> >> > >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> > >> >        "Error Number " & Err.Number & " Occurred"
> >> > >> >    Resume BeforeUpdate_End
> >> > >> > End Sub
> >> > >> >
> >> > >> > The module to pick up the API code is in place...but the bound
> >> > >> > controll
> >> > >> > is
> >> > >> > still not populated i use the above code on a Before Update event
> >> > >> > for
> >> > >> > the
> >> > >> > Form..and the time and date functions....i beleive i am doing
> >> > >> > something
> >> > >> > very
> >> > >> > wrong..
> >> > >> >
> >> > >> > "Tony Toews [MVP]" wrote:
> >> > >> >
> >> > >> >> Peter <Pe***@discussions.microsoft.com> wrote:
> >> > >> >>
> >> > >> >> >And the bottom line is, this is what i need. I want the username
> >> > >> >> >to
> >> > >> >> >be
> >> > >> >> >posted on my opening form (whiwch is always open when the
> >> > >> >> >application
> >> > >> >> >runs)
> >> > >> >> >in order to refer to it later.
> >> > >> >>
> >> > >> >> That's what I was wondering.  Rather than sending you way off
> >> > >> >> into the
> >> > >> >> complex world of Access security.
> >> > >> >>
> >> > >> >> And I see Douglas has replied.
> >> > >> >>
> >> > >> >> >I appologize for my ignorance :-)
> >> > >> >>
> >> > >> >> We don't mind ignorance because we like helping.   So continue to
> >> > >> >> ask
> >> > >> >> away.
> >> > >> >>
> >> > >> >> Tony
> >> > >> >> --
> >> > >> >> Tony Toews, Microsoft Access MVP
> >> > >> >> Tony's Main MS Access pages -
> >> > >> >> http://www.granite.ab.ca/accsmstr.htm
> >> > >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> >> > >> >> Granite Fleet Manager http://www.granitefleet.com/
> >> > >> >>
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> >
> >> >
>
>
>
Author
3 Jun 2009 1:35 AM
David W. Fenton
=?Utf-8?B?UGV0ZXI=?= <Pe***@discussions.microsoft.com> wrote in
news:FA86787B-79C9-43D8-8084-3869312EACE8@microsoft.com:

> nbound textbox with controll source =fOSUserName() works just
> fine..perhaps i should just set an invisible textbox with
> =fOSUserName() and refer to that the following way:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
>     On Error GoTo BeforeUpdate_Err
>
>     ' Set bound controls to system date and time and current user
>     name. Me.DateModified = Date
>     Me.TimeModified = Time()
>     Me.Username = Forms!Spider_reports.UserName

There is absolutely no reason why this shouldn't work:

  Me.Username = fOSUserName()

If the function works in a control, then it should work there.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/
Author
4 Jun 2009 6:29 PM
Peter
Hi Douglas..just for your information i solved this issue the following
way...and also included the Now()..only one controll..and also the Datediff
function..thanks for your patiance..the database is up and running well..you
are a good teacher.

Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo BeforeUpdate_Err

    ' Set bound controls to system date and time and current user name.
    Me.DateModified = Now()
    Me.ModifiedBy = Forms![Username Form].[Operator]

BeforeUpdate_End:
    Exit Sub
BeforeUpdate_Err:
    MsgBox Err.Description, vbCritical & vbOKOnly, _
        "Error Number " & Err.Number & " Occurred"
    Resume BeforeUpdate_End
End Sub

Show quoteHide quote
"Douglas J. Steele" wrote:

> DateDiff works just as well with Date/Time as with Time only.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:1F921D75-7B00-4730-886B-675A50E1D343@microsoft.com...
> > ..and the reson for the seperate Time Date fieled is this idea that i want
> > to
> > caclulate the elapsed tome between time created and time modified in the
> > future..just an experiment...
> >
> > "Peter" wrote:
> >
> >> When i replace my code with yours i receive two small popups after
> >> exiting
> >> the record..i did some edits
> >>
> >> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> >> 2. After: Operator (29/05/2009 17:54:16)
> >>
> >> "Douglas J. Steele" wrote:
> >>
> >> > So you're saying that the DateModified and TimeModified fields are
> >> > being
> >> > updated (why are you storing them in separate fields, btw? You should
> >> > have a
> >> > single field and populate it using the Now function), but that Operator
> >> > isn't? That makes no sense.
> >> >
> >> > For debugging purposes, try the following:
> >> >
> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > On Error GoTo BeforeUpdate_Err
> >> >
> >> >   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
> >> >     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
> >> >     "fOSUserName = " & fOSUserName()
> >> >
> >> > ' Set bound controls to system date and time and current user name.
> >> >   Me.DateModified = Date
> >> >   Me.TimeModified = Time()
> >> >   Me.Operator = fOSUserName()
> >> >
> >> >   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
> >> >     "(" & Me.DateModified & " " & Me.TimeModified & ")"
> >> >
> >> > BeforeUpdate_End:
> >> >   Exit Sub
> >> >
> >> > BeforeUpdate_Err:
> >> >   MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> >     "Error Number " & Err.Number & " Occurred"
> >> >   Resume BeforeUpdate_End
> >> >
> >> > End Sub
> >> >
> >> >
> >> >
> >> > --
> >> > Doug Steele, Microsoft Access MVP
> >> > http://I.Am/DougSteele
> >> > (no private e-mails, please)
> >> >
> >> >
> >> > "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> > news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> >> > > Hoping you are a person of great patiance...-:)..
> >> > >
> >> > > Nope..if i use the below code..it does not update my bounded Operator
> >> > > text
> >> > > field with the current user when i edit this specific record...
> >> > >
> >> > > If i set the control source to = fOSUserName() it populates this text
> >> > > field...but regardless if the record is editet or not..just by
> >> > > opening
> >> > > it...
> >> > >
> >> > > I need to know whois the last person that edited the record...the
> >> > > time and
> >> > > date functions well..displays the current date/time the record was
> >> > > edited...after that i exit the record...thats ok
> >> > >
> >> > > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > >    On Error GoTo BeforeUpdate_Err
> >> > >
> >> > >    ' Set bound controls to system date and time and current user
> >> > > name.
> >> > >    Me.DateModified = Date
> >> > >    Me.TimeModified = Time()
> >> > >    Me.Operator = fOSUserName()
> >> > > BeforeUpdate_End:
> >> > >    Exit Sub
> >> > > BeforeUpdate_Err:
> >> > >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> > >        "Error Number " & Err.Number & " Occurred"
> >> > >    Resume BeforeUpdat
> >> > >
> >> > > "Douglas J. Steele" wrote:
> >> > >
> >> > >> Try using something other than fOSUserName as the name of the text
> >> > >> box.
> >> > >> The
> >> > >> ambiguity is probably confusing Access.
> >> > >>
> >> > >> --
> >> > >> Doug Steele, Microsoft Access MVP
> >> > >> http://I.Am/DougSteele
> >> > >> (no private e-mails, please)
> >> > >>
> >> > >>
> >> > >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> > >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> >> > >> > Ok Tony...i am using this
> >> > >> >
> >> > >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> > >> >    On Error GoTo BeforeUpdate_Err
> >> > >> >
> >> > >> >    ' Set bound controls to system date and time and current user
> >> > >> > name.
> >> > >> >    Me.DateModified = Date
> >> > >> >    Me.TimeModified = Time()
> >> > >> >    Me.fOSUserName = fOSUserName()
> >> > >> > BeforeUpdate_End:
> >> > >> >    Exit Sub
> >> > >> > BeforeUpdate_Err:
> >> > >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> > >> >        "Error Number " & Err.Number & " Occurred"
> >> > >> >    Resume BeforeUpdate_End
> >> > >> > End Sub
> >> > >> >
> >> > >> > The module to pick up the API code is in place...but the bound
> >> > >> > controll
> >> > >> > is
> >> > >> > still not populated i use the above code on a Before Update event
> >> > >> > for
> >> > >> > the
> >> > >> > Form..and the time and date functions....i beleive i am doing
> >> > >> > something
> >> > >> > very
> >> > >> > wrong..
> >> > >> >
> >> > >> > "Tony Toews [MVP]" wrote:
> >> > >> >
> >> > >> >> Peter <Pe***@discussions.microsoft.com> wrote:
> >> > >> >>
> >> > >> >> >And the bottom line is, this is what i need. I want the username
> >> > >> >> >to
> >> > >> >> >be
> >> > >> >> >posted on my opening form (whiwch is always open when the
> >> > >> >> >application
> >> > >> >> >runs)
> >> > >> >> >in order to refer to it later.
> >> > >> >>
> >> > >> >> That's what I was wondering.  Rather than sending you way off
> >> > >> >> into the
> >> > >> >> complex world of Access security.
> >> > >> >>
> >> > >> >> And I see Douglas has replied.
> >> > >> >>
> >> > >> >> >I appologize for my ignorance :-)
> >> > >> >>
> >> > >> >> We don't mind ignorance because we like helping.   So continue to
> >> > >> >> ask
> >> > >> >> away.
> >> > >> >>
> >> > >> >> Tony
> >> > >> >> --
> >> > >> >> Tony Toews, Microsoft Access MVP
> >> > >> >> Tony's Main MS Access pages -
> >> > >> >> http://www.granite.ab.ca/accsmstr.htm
> >> > >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> >> > >> >> Granite Fleet Manager http://www.granitefleet.com/
> >> > >> >>
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> >
> >> >
>
>
>
Author
30 May 2009 5:39 AM
David W. Fenton
=?Utf-8?B?UGV0ZXI=?= <Pe***@discussions.microsoft.com> wrote in
news:6ECEBC05-95BC-41EC-81DA-EEEBC54A2057@microsoft.com:

> When i replace my code with yours i receive two small popups after
> exiting the record..i did some edits
>
> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> 2. After: Operator (29/05/2009 17:54:16)

Your function is not working.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/
Author
30 May 2009 9:42 AM
Peter
I have not changed the name of the Module other then the default,
Module1...the function part of the module was automatically named
fOSUsername...and if i use the controll source in a unbound textfield =
fOSUername ()..it does return the correct value...is there any other way to
bypass this problem...the update event functions well for date and time...so
i know when the record was last edited..but not by whome..

Show quoteHide quote
"David W. Fenton" wrote:

> =?Utf-8?B?UGV0ZXI=?= <Pe***@discussions.microsoft.com> wrote in
> news:6ECEBC05-95BC-41EC-81DA-EEEBC54A2057@microsoft.com:
>
> > When i replace my code with yours i receive two small popups after
> > exiting the record..i did some edits
> >
> > 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> > 2. After: Operator (29/05/2009 17:54:16)
>
> Your function is not working.
>
> --
> David W. Fenton                  http://www.dfenton.com/
> usenet at dfenton dot com    http://www.dfenton.com/DFA/
>
Author
3 Jun 2009 1:33 AM
David W. Fenton
=?Utf-8?B?UGV0ZXI=?= <Pe***@discussions.microsoft.com> wrote in
news:EAC2A363-A642-40CC-835D-C0289C2F7976@microsoft.com:

> I have not changed the name of the Module other then the default,
> Module1...the function part of the module was automatically named
> fOSUsername...and if i use the controll source in a unbound
> textfield = fOSUername ()..it does return the correct value...is
> there any other way to bypass this problem...the update event
> functions well for date and time...so i know when the record was
> last edited..but not by whome..

Well, for one, in what you posted:

>> > 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
>> > 2. After: Operator (29/05/2009 17:54:16)

you misspelled the name of your function. I don't know where you
copied that from, but it ought to throw an error in code, unless you
don't have Option Explicit in the module where you're calling it.

For what it's worth, I use a wrapper function around the function
that makes API call to get the user logon because I think it's
senseless to ask Windows the user logon every time you need to
record it -- it certainly can't change within a single Access
session. So I use the function posted after my signature.

For the function you're using, you'd replace "fGetUserName" with
your function name, "fOSUername". What that code does is it calls it
once and stores it in the Static variable. As long as the Static
variable remains live, it will return the variable and not bother to
ask the OS again.

--
David W. Fenton                  http://www.dfenton.com/
usenet at dfenton dot com    http://www.dfenton.com/DFA/

Public Function UserLogon() As String
  Static strUserLogon As String

  If Len(strUserLogon) = 0 Then
     strUserLogon = fGetUserName()
  End If
  UserLogon = strUserLogon
End Function
Author
30 May 2009 12:20 PM
Douglas J. Steele
Like David says, there's a problem with your fOSUserName function. Are you
sure that it still works if you set the ControlSource of a text box to
=fOSUserName?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:6ECEBC05-95BC-41EC-81DA-EEEBC54A2057@microsoft.com...
> When i replace my code with yours i receive two small popups after exiting
> the record..i did some edits
>
> 1. Before: Operator (29/05/2009 17:51:48) fOSUername =
> 2. After: Operator (29/05/2009 17:54:16)
>
> "Douglas J. Steele" wrote:
>
>> So you're saying that the DateModified and TimeModified fields are being
>> updated (why are you storing them in separate fields, btw? You should
>> have a
>> single field and populate it using the Now function), but that Operator
>> isn't? That makes no sense.
>>
>> For debugging purposes, try the following:
>>
>> Private Sub Form_BeforeUpdate(Cancel As Integer)
>> On Error GoTo BeforeUpdate_Err
>>
>>   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
>>     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
>>     "fOSUserName = " & fOSUserName()
>>
>> ' Set bound controls to system date and time and current user name.
>>   Me.DateModified = Date
>>   Me.TimeModified = Time()
>>   Me.Operator = fOSUserName()
>>
>>   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
>>     "(" & Me.DateModified & " " & Me.TimeModified & ")"
>>
>> BeforeUpdate_End:
>>   Exit Sub
>>
>> BeforeUpdate_Err:
>>   MsgBox Err.Description, vbCritical & vbOKOnly, _
>>     "Error Number " & Err.Number & " Occurred"
>>   Resume BeforeUpdate_End
>>
>> End Sub
>>
>>
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
>> > Hoping you are a person of great patiance...-:)..
>> >
>> > Nope..if i use the below code..it does not update my bounded Operator
>> > text
>> > field with the current user when i edit this specific record...
>> >
>> > If i set the control source to = fOSUserName() it populates this text
>> > field...but regardless if the record is editet or not..just by opening
>> > it...
>> >
>> > I need to know whois the last person that edited the record...the time
>> > and
>> > date functions well..displays the current date/time the record was
>> > edited...after that i exit the record...thats ok
>> >
>> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >    On Error GoTo BeforeUpdate_Err
>> >
>> >    ' Set bound controls to system date and time and current user name.
>> >    Me.DateModified = Date
>> >    Me.TimeModified = Time()
>> >    Me.Operator = fOSUserName()
>> > BeforeUpdate_End:
>> >    Exit Sub
>> > BeforeUpdate_Err:
>> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >        "Error Number " & Err.Number & " Occurred"
>> >    Resume BeforeUpdat
>> >
>> > "Douglas J. Steele" wrote:
>> >
>> >> Try using something other than fOSUserName as the name of the text
>> >> box.
>> >> The
>> >> ambiguity is probably confusing Access.
>> >>
>> >> --
>> >> Doug Steele, Microsoft Access MVP
>> >> http://I.Am/DougSteele
>> >> (no private e-mails, please)
>> >>
>> >>
>> >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
>> >> > Ok Tony...i am using this
>> >> >
>> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >> >    On Error GoTo BeforeUpdate_Err
>> >> >
>> >> >    ' Set bound controls to system date and time and current user
>> >> > name.
>> >> >    Me.DateModified = Date
>> >> >    Me.TimeModified = Time()
>> >> >    Me.fOSUserName = fOSUserName()
>> >> > BeforeUpdate_End:
>> >> >    Exit Sub
>> >> > BeforeUpdate_Err:
>> >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >> >        "Error Number " & Err.Number & " Occurred"
>> >> >    Resume BeforeUpdate_End
>> >> > End Sub
>> >> >
>> >> > The module to pick up the API code is in place...but the bound
>> >> > controll
>> >> > is
>> >> > still not populated i use the above code on a Before Update event
>> >> > for
>> >> > the
>> >> > Form..and the time and date functions....i beleive i am doing
>> >> > something
>> >> > very
>> >> > wrong..
>> >> >
>> >> > "Tony Toews [MVP]" wrote:
>> >> >
>> >> >> Peter <Pe***@discussions.microsoft.com> wrote:
>> >> >>
>> >> >> >And the bottom line is, this is what i need. I want the username
>> >> >> >to
>> >> >> >be
>> >> >> >posted on my opening form (whiwch is always open when the
>> >> >> >application
>> >> >> >runs)
>> >> >> >in order to refer to it later.
>> >> >>
>> >> >> That's what I was wondering.  Rather than sending you way off into
>> >> >> the
>> >> >> complex world of Access security.
>> >> >>
>> >> >> And I see Douglas has replied.
>> >> >>
>> >> >> >I appologize for my ignorance :-)
>> >> >>
>> >> >> We don't mind ignorance because we like helping.   So continue to
>> >> >> ask
>> >> >> away.
>> >> >>
>> >> >> Tony
>> >> >> --
>> >> >> Tony Toews, Microsoft Access MVP
>> >> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> >> >> Granite Fleet Manager http://www.granitefleet.com/
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
Author
1 Jun 2009 11:19 AM
Peter
Hmm..does access need to modify the advapi32.dll...i am not the administrator
on my system...just thinking loud

Show quoteHide quote
"Douglas J. Steele" wrote:

> So you're saying that the DateModified and TimeModified fields are being
> updated (why are you storing them in separate fields, btw? You should have a
> single field and populate it using the Now function), but that Operator
> isn't? That makes no sense.
>
> For debugging purposes, try the following:
>
> Private Sub Form_BeforeUpdate(Cancel As Integer)
> On Error GoTo BeforeUpdate_Err
>
>   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
>     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
>     "fOSUserName = " & fOSUserName()
>
> ' Set bound controls to system date and time and current user name.
>   Me.DateModified = Date
>   Me.TimeModified = Time()
>   Me.Operator = fOSUserName()
>
>   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
>     "(" & Me.DateModified & " " & Me.TimeModified & ")"
>
> BeforeUpdate_End:
>   Exit Sub
>
> BeforeUpdate_Err:
>   MsgBox Err.Description, vbCritical & vbOKOnly, _
>     "Error Number " & Err.Number & " Occurred"
>   Resume BeforeUpdate_End
>
> End Sub
>
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
> > Hoping you are a person of great patiance...-:)..
> >
> > Nope..if i use the below code..it does not update my bounded Operator text
> > field with the current user when i edit this specific record...
> >
> > If i set the control source to = fOSUserName() it populates this text
> > field...but regardless if the record is editet or not..just by opening
> > it...
> >
> > I need to know whois the last person that edited the record...the time and
> > date functions well..displays the current date/time the record was
> > edited...after that i exit the record...thats ok
> >
> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >    On Error GoTo BeforeUpdate_Err
> >
> >    ' Set bound controls to system date and time and current user name.
> >    Me.DateModified = Date
> >    Me.TimeModified = Time()
> >    Me.Operator = fOSUserName()
> > BeforeUpdate_End:
> >    Exit Sub
> > BeforeUpdate_Err:
> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >        "Error Number " & Err.Number & " Occurred"
> >    Resume BeforeUpdat
> >
> > "Douglas J. Steele" wrote:
> >
> >> Try using something other than fOSUserName as the name of the text box.
> >> The
> >> ambiguity is probably confusing Access.
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no private e-mails, please)
> >>
> >>
> >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
> >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
> >> > Ok Tony...i am using this
> >> >
> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
> >> >    On Error GoTo BeforeUpdate_Err
> >> >
> >> >    ' Set bound controls to system date and time and current user name.
> >> >    Me.DateModified = Date
> >> >    Me.TimeModified = Time()
> >> >    Me.fOSUserName = fOSUserName()
> >> > BeforeUpdate_End:
> >> >    Exit Sub
> >> > BeforeUpdate_Err:
> >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
> >> >        "Error Number " & Err.Number & " Occurred"
> >> >    Resume BeforeUpdate_End
> >> > End Sub
> >> >
> >> > The module to pick up the API code is in place...but the bound controll
> >> > is
> >> > still not populated i use the above code on a Before Update event for
> >> > the
> >> > Form..and the time and date functions....i beleive i am doing something
> >> > very
> >> > wrong..
> >> >
> >> > "Tony Toews [MVP]" wrote:
> >> >
> >> >> Peter <Pe***@discussions.microsoft.com> wrote:
> >> >>
> >> >> >And the bottom line is, this is what i need. I want the username to
> >> >> >be
> >> >> >posted on my opening form (whiwch is always open when the application
> >> >> >runs)
> >> >> >in order to refer to it later.
> >> >>
> >> >> That's what I was wondering.  Rather than sending you way off into the
> >> >> complex world of Access security.
> >> >>
> >> >> And I see Douglas has replied.
> >> >>
> >> >> >I appologize for my ignorance :-)
> >> >>
> >> >> We don't mind ignorance because we like helping.   So continue to ask
> >> >> away.
> >> >>
> >> >> Tony
> >> >> --
> >> >> Tony Toews, Microsoft Access MVP
> >> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> >> >> Granite Fleet Manager http://www.granitefleet.com/
> >> >>
> >>
> >>
> >>
>
>
>
Author
1 Jun 2009 9:29 PM
Douglas J. Steele
Shouldn't need to be administrator, and I'm unaware of any interactions
between Access and advapi32.dll

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Show quoteHide quote
"Peter" <Pe***@discussions.microsoft.com> wrote in message
news:78CC68FB-C296-430D-A8E0-1F9D365ABB4D@microsoft.com...
> Hmm..does access need to modify the advapi32.dll...i am not the
> administrator
> on my system...just thinking loud
>
> "Douglas J. Steele" wrote:
>
>> So you're saying that the DateModified and TimeModified fields are being
>> updated (why are you storing them in separate fields, btw? You should
>> have a
>> single field and populate it using the Now function), but that Operator
>> isn't? That makes no sense.
>>
>> For debugging purposes, try the following:
>>
>> Private Sub Form_BeforeUpdate(Cancel As Integer)
>> On Error GoTo BeforeUpdate_Err
>>
>>   MsgBox "Before: Operator " & Me.Operator & vbCrLf & _
>>     "(" & Me.DateModified & " " & Me.TimeModified & ")" & vbCrLf & _
>>     "fOSUserName = " & fOSUserName()
>>
>> ' Set bound controls to system date and time and current user name.
>>   Me.DateModified = Date
>>   Me.TimeModified = Time()
>>   Me.Operator = fOSUserName()
>>
>>   MsgBox "After: Operator " & Me.Operator & vbCrLf & _
>>     "(" & Me.DateModified & " " & Me.TimeModified & ")"
>>
>> BeforeUpdate_End:
>>   Exit Sub
>>
>> BeforeUpdate_Err:
>>   MsgBox Err.Description, vbCritical & vbOKOnly, _
>>     "Error Number " & Err.Number & " Occurred"
>>   Resume BeforeUpdate_End
>>
>> End Sub
>>
>>
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> news:37539BC6-CD75-4A79-8B79-DA437515157A@microsoft.com...
>> > Hoping you are a person of great patiance...-:)..
>> >
>> > Nope..if i use the below code..it does not update my bounded Operator
>> > text
>> > field with the current user when i edit this specific record...
>> >
>> > If i set the control source to = fOSUserName() it populates this text
>> > field...but regardless if the record is editet or not..just by opening
>> > it...
>> >
>> > I need to know whois the last person that edited the record...the time
>> > and
>> > date functions well..displays the current date/time the record was
>> > edited...after that i exit the record...thats ok
>> >
>> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >    On Error GoTo BeforeUpdate_Err
>> >
>> >    ' Set bound controls to system date and time and current user name.
>> >    Me.DateModified = Date
>> >    Me.TimeModified = Time()
>> >    Me.Operator = fOSUserName()
>> > BeforeUpdate_End:
>> >    Exit Sub
>> > BeforeUpdate_Err:
>> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >        "Error Number " & Err.Number & " Occurred"
>> >    Resume BeforeUpdat
>> >
>> > "Douglas J. Steele" wrote:
>> >
>> >> Try using something other than fOSUserName as the name of the text
>> >> box.
>> >> The
>> >> ambiguity is probably confusing Access.
>> >>
>> >> --
>> >> Doug Steele, Microsoft Access MVP
>> >> http://I.Am/DougSteele
>> >> (no private e-mails, please)
>> >>
>> >>
>> >> "Peter" <Pe***@discussions.microsoft.com> wrote in message
>> >> news:97AF0568-9C8B-4BCA-AF0E-16DB54BA6E84@microsoft.com...
>> >> > Ok Tony...i am using this
>> >> >
>> >> > Private Sub Form_BeforeUpdate(Cancel As Integer)
>> >> >    On Error GoTo BeforeUpdate_Err
>> >> >
>> >> >    ' Set bound controls to system date and time and current user
>> >> > name.
>> >> >    Me.DateModified = Date
>> >> >    Me.TimeModified = Time()
>> >> >    Me.fOSUserName = fOSUserName()
>> >> > BeforeUpdate_End:
>> >> >    Exit Sub
>> >> > BeforeUpdate_Err:
>> >> >    MsgBox Err.Description, vbCritical & vbOKOnly, _
>> >> >        "Error Number " & Err.Number & " Occurred"
>> >> >    Resume BeforeUpdate_End
>> >> > End Sub
>> >> >
>> >> > The module to pick up the API code is in place...but the bound
>> >> > controll
>> >> > is
>> >> > still not populated i use the above code on a Before Update event
>> >> > for
>> >> > the
>> >> > Form..and the time and date functions....i beleive i am doing
>> >> > something
>> >> > very
>> >> > wrong..
>> >> >
>> >> > "Tony Toews [MVP]" wrote:
>> >> >
>> >> >> Peter <Pe***@discussions.microsoft.com> wrote:
>> >> >>
>> >> >> >And the bottom line is, this is what i need. I want the username
>> >> >> >to
>> >> >> >be
>> >> >> >posted on my opening form (whiwch is always open when the
>> >> >> >application
>> >> >> >runs)
>> >> >> >in order to refer to it later.
>> >> >>
>> >> >> That's what I was wondering.  Rather than sending you way off into
>> >> >> the
>> >> >> complex world of Access security.
>> >> >>
>> >> >> And I see Douglas has replied.
>> >> >>
>> >> >> >I appologize for my ignorance :-)
>> >> >>
>> >> >> We don't mind ignorance because we like helping.   So continue to
>> >> >> ask
>> >> >> away.
>> >> >>
>> >> >> Tony
>> >> >> --
>> >> >> Tony Toews, Microsoft Access MVP
>> >> >> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
>> >> >> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
>> >> >> Granite Fleet Manager http://www.granitefleet.com/
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>

Bookmark and Share