[AccessD] Populate field with userid Environ A97 vs A2k+

O'Connor, Patricia (OTDA) Patricia.O'Connor at otda.state.ny.us
Wed Nov 21 09:05:54 CST 2007


Arthur
I will give this a try
Thank you 
Patti
**************************************************
* Patricia O'Connor
* Associate Computer Programmer Analyst
* OTDA - BDMA
* (W) mailto:Patricia.O'Connor at otda.state.ny.us
* (w) mailto:aa1160 at nysemail.state.ny.us
**************************************************
 

> 
--------------------------------------------------------
This e-mail, including any attachments, may be confidential, privileged or otherwise legally protected. It is intended only for the addressee. If you received this e-mail in error or from someone who was not authorized to send it to you, do not disseminate, copy or otherwise use this e-mail or its attachments.  Please notify the sender immediately by reply e-mail and delete the e-mail from your system. 


-----Original Message-----

> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> Arthur Fuller
> Sent: Tuesday, November 20, 2007 03:36 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Populate field with userid Environ A97 vs A2k+
> 
> Will this do?
> 
> <Code>
> Option Compare Database
> Option Explicit
> Global Const SW_SHOWNORMAL = 1
> 
> Public Declare Function ShellExecute Lib "shell32.dll" Alias 
> "ShellExecuteA"
> _
>     (ByVal hwnd As Long, _
>     ByVal lpOperation As String, _
>     ByVal lpFile As String, _
>     ByVal lpParameters As String, _
>     ByVal lpDirectory As String, _
>     ByVal nShowCmd As Long) As Long
> 
> '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
> 
> Public 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 = ""
>    End If
> End Function
> </Code>
> 
> hth,
> Arthur
> 
> On 11/20/07, O'Connor, Patricia (OTDA) 
> <Patricia.O'Connor at otda.state.ny.us>
> wrote:
> >
> > Thank you - I had a feeling there might not be a work around
> >
> > The table was not being updated in, with or by a form when 
> the error 
> > occurred.
> >
> > Wanted to insure I knew the last person at the record.  It was 
> > something that worked fine for 10 years - m$ could have 
> made it read 
> > only if modifying was a problem .
> >
> > **************************************************
> > * Patricia O'Connor
> > * Associate Computer Programmer Analyst
> > * OTDA - BDMA
> > * (W) mailto:Patricia.O'Connor at otda.state.ny.us
> > * (w) mailto:aa1160 at nysemail.state.ny.us
> > **************************************************
> >
> >
> > >
> > --------------------------------------------------------
> > This e-mail, including any attachments, may be confidential, 
> > privileged or otherwise legally protected. It is intended 
> only for the 
> > addressee. If you received this e-mail in error or from someone who 
> > was not authorized to send it to you, do not disseminate, copy or 
> > otherwise use this e-mail or its attachments.  Please notify the 
> > sender immediately by reply e-mail and delete the e-mail 
> from your system.
> >
> >
> > -----Original Message-----
> >
> > > From: accessd-bounces at databaseadvisors.com
> > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf 
> Of Heenan, 
> > > Lambert
> > > Sent: Tuesday, November 20, 2007 01:30 PM
> > > To: 'Access Developers discussion and problem solving'
> > > Subject: Re: [AccessD] Populate field with userid Environ A97 vs 
> > > A2k+
> > >
> > > Is there a workaround? No. You have to use an API call to get the 
> > > user ID.
> > > So quit defaulting these fields in your tables and add a 
> tiny bit of 
> > > code to the BeforeInsert (for new records) and BeforeUpdate (for 
> > > edits) events on your forms.
> > >
> > > There's only a very limited list of functions you can use in the 
> > > default value property of field in table design view. It was even 
> > > documented once, but I'm damned if I can locate it in the 
> Access XP 
> > > help file. Oh well.
> > >
> > > BTW it also makes sense to not allow Environ(). Environ 
> is a risky 
> > > proposition because it is quite easy for a user to change an 
> > > environment variable, (like "USERNAME") and so potentially bypass 
> > > 'security'.
> > >
> > > Lambert
> > >
> > > -----Original Message-----
> > > From: accessd-bounces at databaseadvisors.com
> > > [mailto:accessd-bounces at databaseadvisors.com] On Behalf 
> Of O'Connor, 
> > > Patricia (OTDA)
> > > Sent: Tuesday, November 20, 2007 12:34 PM
> > > To: Access Developers discussion and problem solving
> > > Subject: [AccessD] Populate field with userid Environ A97 vs A2k+
> > >
> > >
> > > I am upgrading an Access97 to Access2k to Access2k3.  I 
> know about 
> > > having to create a function to use it in A2k and A2k3 (GRRR)
> > >
> > > I have been using =Environ("UserName") to populate a field
> > > (LastUpdtBy) in a new record in my A97-tables for years.
> > >
> > > I created the function that was recommended and it works in my 
> > > vb/vba code portions. It is not working in the table 
> field default.  
> > > Gives me the runtime error # 3388 "unknown function 'Environ'.
> > >
> > > Is there a workaround?  If there is one in the archives, 
> please send 
> > > a complete link. I have tried finding something suggested 
> in mails 
> > > but can't find them easily.
> > >
> > > I still think this ban was ridiculous or at least they 
> should have 
> > > created a valid totally useable workaround
> > >
> > > Thanks -  Have a wonderful Thanksgiving ALL Patti
> > > **************************************************
> > > * Patricia O'Connor
> > > * Associate Computer Programmer Analyst
> > > * OTDA - BDMA
> > > * (W) mailto:Patricia.O'Connor at otda.state.ny.us
> > > * (w) mailto:aa1160 at nysemail.state.ny.us
> > > **************************************************
> > > --------------------------------------------------------
> > > This e-mail, including any attachments, may be confidential, 
> > > privileged or otherwise legally protected. It is intended 
> only for 
> > > the addressee. If you received this e-mail in error or 
> from someone 
> > > who was not authorized to send it to you, do not 
> disseminate, copy 
> > > or otherwise use this e-mail or its attachments.  Please 
> notify the 
> > > sender immediately by reply e-mail and delete the e-mail 
> from your 
> > > system.
> > >
> > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
>





More information about the AccessD mailing list