Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access On Open Event. Need code to compare userName & EmpNum?

Status
Not open for further replies.

Labadore

Programmer
Apr 13, 2001
17
US
(MS Access)
I am capable of filtering the user when logging in to windows with this in the module:
Private Declare Function WNetGetUserA Lib "mpr" _
(ByVal lpName As String, ByVal lpUserName As _
String, lpnLength As Long) As Long

Function GetUser() As String
Dim sUserNameBuff As String * 255
sUserNameBuff = Space(255)
Call WNetGetUserA(vbNullString, sUserNameBuff, 255&)
GetUser = Left$(sUserNameBuff, InStr(sUserNameBuff, _
vbNullChar) - 1)

and this in the on open event on the form:

Private Sub Form_Open(Cancel As Integer)

Usr = GetUser()
If Usr <> &quot;xxx&quot; Or Usr <> &quot;xxx&quot; Or Usr <> &quot;xxx&quot; Then
Application.SetOption &quot;Show Hidden Objects&quot;, False
End If
If Usr = &quot;xxx&quot; Or Usr = &quot;xxx&quot; Or Usr = &quot;xxx&quot; Or Usr = &quot;xxx&quot; Then
Usr = InputBox(&quot;Enter User Name&quot;, &quot;Test&quot;, Usr)
End If
cmdFind.Visible = True
end sub

What I need to do is match userLogin with empNo(primary key) which these fields are in the same table. The way i need it is that when the user logs in the form only displays that particular empNo records and no others...Makes sense...I just don't know what the code would be like. Please if any of you guru's can help I would appreciate it. Thank You
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top