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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email username from Access VBA module

Status
Not open for further replies.

ch4meleon

Technical User
Jan 13, 2003
60
GB
I have code set up that establishes the username and decides if that user is allowed to go into the database, it works via the event of the switchboard form opening.
i want to email the username of people that are refused entry to someone so they can keep tabs on attempts at unauthorised entry.
the 2 bits of code are -

Function Get_User_Name()

Dim lpBuff As String * 25
Dim z As String
Dim ret As Long
ret = GetUserName(lpBuff, 25)
username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
z = username
End Function


and

Sub Form_Open(Cancel As Integer)



Get_User_Name



If username = "joe.brown" Then
Exit Sub
ElseIf username = "john.smith" Then
Exit Sub
ElseIf username = "jane.thomas" Then
Exit Sub
Else
MsgBox "Sorry you are not authorised to go in here ", vbExclamation,
Application.Quit
End If

 
Hi
Are you looking for a way to email? Try thread705-1026158 (VB Slammer).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top