Question for Dave Hargis or Dev Ashish

C

CW

I saw Dave's response to a post about popup reminders, where he referred to
the api to get details of the logged on network user.

I would find that very useful in another scenario, but am not sure how to
use it - does the code go behind the click event of a cmd button, or what?
And once you've got the info, how do you retain it and refer to it - for
example, to record who has entered or updated certain data - obviously it
can't be stored as it is subject to constant change...
Many thanks
CW
 
K

Klatuu

The code should go in a standard module by itself.
This is a pretty good rule to follow for any api code you download.

Where you call the code depends on where you need it. It is like any other
function. You Dim a varialbe to accept the return value of the function or
you can use the function as you would a variable as in the example below. As
to storing it, if you need to store the value, you would need to create a
table for all your users so you would know what to do based on who the user
is.

In this example, I am doing a call to GetUserID in the DLookup function to
return the value of the current user to be validated by the DLookup. In the
application that is being opened, I am verifying the user is a valid user of
the the application and that the TestDirector Password has been entered for
this user. It allows the user to enter his/her TD Password the first time
he/she logs into the system.

If strVerClient = strVerServer Then
Me.Visible = False
DoEvents
If IsNull(DLookup("[TestDirectorPassword]", "dbo_Employee", _
"[EmployeeLogin] = """ & GetUserID & """")) Then
DoCmd.OpenForm "frmTdPwd"
Else
DoCmd.OpenForm "frmDashBoard"
End If

Else
 
C

CW

OK, got it. Thanks for the example, I can see just how it works now.
Much appreciated
CW

Klatuu said:
The code should go in a standard module by itself.
This is a pretty good rule to follow for any api code you download.

Where you call the code depends on where you need it. It is like any other
function. You Dim a varialbe to accept the return value of the function or
you can use the function as you would a variable as in the example below. As
to storing it, if you need to store the value, you would need to create a
table for all your users so you would know what to do based on who the user
is.

In this example, I am doing a call to GetUserID in the DLookup function to
return the value of the current user to be validated by the DLookup. In the
application that is being opened, I am verifying the user is a valid user of
the the application and that the TestDirector Password has been entered for
this user. It allows the user to enter his/her TD Password the first time
he/she logs into the system.

If strVerClient = strVerServer Then
Me.Visible = False
DoEvents
If IsNull(DLookup("[TestDirectorPassword]", "dbo_Employee", _
"[EmployeeLogin] = """ & GetUserID & """")) Then
DoCmd.OpenForm "frmTdPwd"
Else
DoCmd.OpenForm "frmDashBoard"
End If

Else


--
Dave Hargis, Microsoft Access MVP


CW said:
I saw Dave's response to a post about popup reminders, where he referred to
the api to get details of the logged on network user.

I would find that very useful in another scenario, but am not sure how to
use it - does the code go behind the click event of a cmd button, or what?
And once you've got the info, how do you retain it and refer to it - for
example, to record who has entered or updated certain data - obviously it
can't be stored as it is subject to constant change...
Many thanks
CW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top