[AccessD] Help on entering data -- when to do it?

rockysmolin bchacc.com rockysmolin at bchacc.com
Tue Dec 24 11:13:40 CST 2019


Do don't want to update the user ID each time the record is accessed and changed?  Then use the On Dirty event.  Do you want to insert the user ID on the first time the record is created and then not change it again? Use the Before Insert event.

r

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W. Clark
Sent: Tuesday, December 24, 2019 6:28 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Help on entering data -- when to do it?

I have the userID. I use a module called modGetNetID and in that module I have the following:

Public Function GetUserName() As String
    ' GetUserName = Environ("USERNAME")
    ' Better method, see comment by HansUp
    GetUserName = CreateObject("WScript.Network").UserName
End Function

(I left the commenting in obviously)

I then call it in the Form_Current and Form_Load events. This seems to work in both (in regards to presenting it) and I'm not sure which to go with yet. I use the following code behind the events: txtNetID.Value = Environ("Username")

I have that field (txtNetID) with the Control Source of txtInputUser and it is populating the table with the correct information.

My problem is that I am using the same form for input and viewing/editing the current data -- like I said, this program was actually written by another, and this isn't something I wanted to spend too much time on because, while I still love programming, I just have too many other responsibilities these days. So I just prettied up their entry form and it opens to a blank record (and the UserID is in there for this). To get to the rest I'm OK having the user just click on the "filter" button at the bottom. But this isn't working while there is a UserID in that field -- if you hit escape, it clears that box and one can then click on "filter." But, while I am getting to the point where I may just have them do this, I really don't want to.

So, I was wondering if there was a better event to use.

Also, I notice that when I click on the filter button again, and it comes back to a blank record, that field is not populated now. I've setup an "OnClick" event to do this, but again, that is just a bit past the hokie mark and I really don't want to do that.

Perhaps I am becoming like my users and asking for too much here, eh? ;o)



________________________________
From: AccessD <accessd-bounces at databaseadvisors.com> on behalf of Stuart McLachlan <stuart at lexacorp.com.pg>
Sent: Monday, December 23, 2019 7:23 PM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Help on entering data -- when to do it?

[EXTERNAL MESSAGE]

This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
- Niagara County IT

I use.a form of Jake's GetUserName API call to get the usernae.

There are a couple of ways to use it.

You can set it is the Before_Insert or Before_Update form event (depending on whether you
want to know who originally created the record who last modifed the record.

Alternatively, you can have a text box  on your form bound to the ID and set it's default value
to "=GetUserName()".  You can use any combination of Enabled/Locked/Visible for the
textbox accordiing to your requireents.

Personally, I tend to use the latter ethod.



On 23 Dec 2019 at 22:04, Bob Walsh wrote:

> John,
>
> If you get the userid when you start the application and store it in a
> Tempvars, it will be available for you to use everywhere in the
> application.
>
> Bob
>
> From: AccessD <accessd-bounces at databaseadvisors.com> On Behalf Of John
> W. Clark Sent: Monday, December 23, 2019 10:38 AM To: Access
> Developers discussion and problem solving
> <accessd at databaseadvisors.com> Subject: [AccessD] Help on entering
> data -- when to do it?
>
> [Attn: This is an external email.]
>
> Hey All! There are probably many people here who many not remember me.
> It has been a very long time since asking any questions here. This is
> because, (A) because of the list I became quite proficient, and (B) I
> haven't worked with Access in a very long time -- I've done some
> little stuff here and there, but no programming in a while. I now
> inherited one of my favorite tasks (I'm being very sarcastic here) and
> I am fixing the code of someone who is a non-programmer and wrote code
> that a department now wants to use.
>
> Maybe it is because I have become rusty, but I now find myself needing
> some help. I've got it mostly working, but I have one little issue at
> the moment -- I added a field to find the user ID of the person logged
> in, and I want to be able to put that in the record, so we can track
> who made the entry. I initially did this for the onOpen event of the
> form, but now I am unable to turn off filtering and scroll through all
> the records. I can hit ESC and then do this, but I don't want the user
> to have to do this. So I'm thinking I need to assign that field
> elsewhere -- perhaps OnDirty? That is what I am asking -- at what
> point should I be putting this in? I never used the even OnDirty in
> all the years I programmed -- don't know why; just never needed to --
> so I'm a bit shaky on what it means exactly. Or perhaps there is a
> better way to do this?
>
>
> Notice: This electronic transmission is intended for the sole use of
> the individual or entity to which it is addressed and may contain
> confidential, privileged or otherwise legally protected information.
> If you are not the intended recipient, or if you believe you are not
> the intended recipient, you are hereby notified that any use,
> disclosure, copying, distribution, or the taking of any action in
> reliance on the contents of this information, is strictly prohibited.
> Niagara County is not responsible for the content of any external
> hyperlink referenced in this email or any email. IF YOU HAVE RECEIVED
> THIS TRANSMISSION IN ERROR, PLEASE NOTIFY THE SENDER IMMEDIATELY BY
> EMAIL AND DELETE THE ORIGINAL MESSAGE ALONG WITH ANY PAPER OR
> ELECTRONIC COPIES. Thank you for your cooperation. -- AccessD mailing
> list AccessD at databaseadvisors.com<mailto:AccessD at databaseadvisors.com>
> http://databaseadvisors.com/mailman/listinfo/accessd<http://databasead
> visors.com/mailman/listinfo/accessd> Website:
> http://www.databaseadvisors.com<http://www.databaseadvisors.com>
>
> ________________________________
> This message and any attachments are intended for the use of the
> individual to whom it is addressed and may contain information that is
> privileged, business sensitive, confidential and/or exempt from
> disclosure under applicable laws and regulations. If you are not the
> intended recipient, be aware that any disclosure, copying,
> distribution, or use of the contents of this transmission is
> prohibited. If you have received this message in error, please inform
> the sender and delete all copies. Thank you. -- 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


Notice: This electronic transmission is intended for the sole use of the individual or entity to which it is addressed and may contain confidential, privileged or otherwise legally protected information. If you are not the intended recipient, or if you believe you are not the intended recipient, you are hereby notified that any use, disclosure, copying, distribution, or the taking of any action in reliance on the contents of this information, is strictly prohibited. Niagara County is not responsible for the content of any external hyperlink referenced in this email or any email. IF YOU HAVE RECEIVED THIS TRANSMISSION IN ERROR, PLEASE NOTIFY THE SENDER IMMEDIATELY BY EMAIL AND DELETE THE ORIGINAL MESSAGE ALONG WITH ANY PAPER OR ELECTRONIC COPIES. Thank you for your cooperation.
-- 
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