473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

generate list of log-ins

Thanks in advance! I have an un-secured database that I can see which
computer name is logged-on but not the user. I have an error module
that can get the user name. It writes to an error file.

What I'd like to do is to have an invisible error generated that would
post to this log, but do nothing else. Any ideas?

My error log works like this:

Call LogErr
'this calls my module named: modErrorLog:

Option Compare Database
Option Explicit

Public Sub LogErr(ByVal strEvent As String, ByVal strForm As String, _
ByVal bolShowMsg As Boolean)

Dim cnn As New ADODB.Connection
Dim rec As New ADODB.Recordset
Dim strSQL As String
Dim strUser As String
Dim strPC As String
Dim lngNum As Long

Dim objAPI As New clsAPI

With objAPI
strPC = .ComputerName
strUser = .UserName
End With

Set cnn = CurrentProject.Connection
cnn.CursorLocation = adUseClient
strSQL = "SELECT * FROM tblErrors"

rec.Open strSQL, cnn, adOpenKeyset, adLockOptimistic

Debug.Print rec.Supports(adAddNew)

With rec
.AddNew
.Fields("UserName").Value = strUser
.Fields("ComputerName").Value = strPC
.Update
End With

rec.Close
cnn.Close
Set cnn = Nothing
Set objAPI = Nothing

End Sub

Apr 17 '06 #1
6 1465
do you have to generate an error? why not just call the procedure from the
Open event of the first form that opens (switchboard? main menu?) when the
db opens?

hth
"Parasyke" <kr************@yahoo.com> wrote in message
news:11*********************@i40g2000cwc.googlegro ups.com...
Thanks in advance! I have an un-secured database that I can see which
computer name is logged-on but not the user. I have an error module
that can get the user name. It writes to an error file.

What I'd like to do is to have an invisible error generated that would
post to this log, but do nothing else. Any ideas?

My error log works like this:

Call LogErr
'this calls my module named: modErrorLog:

Option Compare Database
Option Explicit

Public Sub LogErr(ByVal strEvent As String, ByVal strForm As String, _
ByVal bolShowMsg As Boolean)

Dim cnn As New ADODB.Connection
Dim rec As New ADODB.Recordset
Dim strSQL As String
Dim strUser As String
Dim strPC As String
Dim lngNum As Long

Dim objAPI As New clsAPI

With objAPI
strPC = .ComputerName
strUser = .UserName
End With

Set cnn = CurrentProject.Connection
cnn.CursorLocation = adUseClient
strSQL = "SELECT * FROM tblErrors"

rec.Open strSQL, cnn, adOpenKeyset, adLockOptimistic

Debug.Print rec.Supports(adAddNew)

With rec
.AddNew
.Fields("UserName").Value = strUser
.Fields("ComputerName").Value = strPC
.Update
End With

rec.Close
cnn.Close
Set cnn = Nothing
Set objAPI = Nothing

End Sub

Apr 17 '06 #2
Upon trying that:

Private Sub Form_Open(Cancel As Integer)
Call ErrorLog
End Sub

I get a compile error "Ambiguous Name Detected"

Apr 17 '06 #3
BTW: I wouldn't necessarily need to use this Error module if I could
find another way to write to a table the user name and the computer
name which my error handler does. If I use a module I got (which works
well) from http://www.mvps.org/access/modules/mdl0055.htm, all I get
tis the computer name and "unknown user".

Apr 17 '06 #4
well, the name of the procedure that you posted is "LogErr". have you tried
calling that, as

Private Sub Form_Open(Cancel As Integer)
LogErr
End Sub

i imagine you'll get a compile error requiring that you supply values to the
procedure's arguments (strEvent, strForm, and bolShowMsg), but since i
didn't see any of those variables used in the procedure, it shouldn't really
matter what values you pass.

btw, i've never heard of "calling" an entire module, only a procedure in a
module - though of course i haven't heard of everything, by a long shot. at
any rate, suggest you try the above OpenForm code, and see if it works for
you.

hth
"Parasyke" <kr************@yahoo.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Upon trying that:

Private Sub Form_Open(Cancel As Integer)
Call ErrorLog
End Sub

I get a compile error "Ambiguous Name Detected"

Apr 18 '06 #5
Add the code below to a module, and call the function called fOSUserName()
from the on open event of your form, and that will give you the user name
logged onto the PC.

-----
Option Compare Database
Option Explicit

'******************** Code Start **************************
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)

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
-------------------------------

Regards
SB.

"Parasyke" <kr************@yahoo.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
BTW: I wouldn't necessarily need to use this Error module if I could
find another way to write to a table the user name and the computer
name which my error handler does. If I use a module I got (which works
well) from http://www.mvps.org/access/modules/mdl0055.htm, all I get
tis the computer name and "unknown user".

Apr 18 '06 #6
In my module the following is displaying in red:

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

The compile message seems to be expecting a "String Constant".

Apr 18 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bart Nessux | last post by:
Hi, I am generating a list of file names... some of the files are locked by the OS (Windows XP) and I know the names of these files (NTUSER.DAT, ntuser.dat.LOG, etc.) But, I don't know their...
1
by: barnesc | last post by:
Hi again, Since my linear algebra library appears not to serve any practical need (I found cgkit, and that works better for me), I've gotten bored and went back to one of my other projects:...
10
by: Andrew McLellan | last post by:
I think I must be missing something about generics, perhaps just about the syntax. I'd like to derive a class MyList from System.Collections.Generic so that it can only contain instance of MyItem....
0
by: Dan | last post by:
We are wanting to use ibuyspy portal as our website. Load content into HTML and change the stylesheet. We see this as very attractive since frequently changed pages can be done in MS word and...
6
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are...
10
by: pamelafluente | last post by:
Hi I have a sorted list with several thousands items. In my case, but this is not important, objects are stored only in Keys, Values are all Nothing. Several of the stored objects (might be a...
1
by: vinaykeshav | last post by:
If we have written code at global.ascx.cs to handle error and writing it to a log and accidently the web.dll gets deleted and at the web.config even if the redirection happens to error page it will...
4
by: fAnSKyer | last post by:
When using random we can get a uniform data sample. But how to transfer this sample in to a Guassion Sample? Thanks? Did C or C++ provide any function to do this? Thanks a lot. Cheers. fAnS.
1
by: Rahul83 | last post by:
Hi.. I have written a perl script for displaying the difference between two directory structures.(including the diffferences in the files) I have to generate the output in a log file. ...
30
ADezii
by: ADezii | last post by:
For this Tip, we will show you an extremely handy, multi-user, feature of Jet that allows you to manage Users more effectively. You can create a special, provider-specific Recordset in ADO that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.