473,666 Members | 2,181 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Connectio n
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.CursorLocat ion = adUseClient
strSQL = "SELECT * FROM tblErrors"

rec.Open strSQL, cnn, adOpenKeyset, adLockOptimisti c

Debug.Print rec.Supports(ad AddNew)

With rec
.AddNew
.Fields("UserNa me").Value = strUser
.Fields("Comput erName").Value = strPC
.Update
End With

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

End Sub

Apr 17 '06 #1
6 1480
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******** *************@i 40g2000cwc.goog legroups.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.Connectio n
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.CursorLocat ion = adUseClient
strSQL = "SELECT * FROM tblErrors"

rec.Open strSQL, cnn, adOpenKeyset, adLockOptimisti c

Debug.Print rec.Supports(ad AddNew)

With rec
.AddNew
.Fields("UserNa me").Value = strUser
.Fields("Comput erName").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(Cance l 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(Cance l 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.goo glegroups.com.. .
Upon trying that:

Private Sub Form_Open(Cance l 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.d ll" Alias
"GetUserNam eA" (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$(strUserNa me, lngLen - 1)
Else
fOSUserName = ""
End If
End Function
-------------------------------

Regards
SB.

"Parasyke" <kr************ @yahoo.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.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.d ll" Alias
"GetUserNam eA" (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
2625
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 position in the list. Is there a way that I can delete these items from the list based on their names? Thanks, Bart
1
485
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: reimplementing the Python builtin classes list(), set(), dict(), and frozenset() with balanced trees (specifically, counted B-trees stored in memory). In short, this allows list lookup, insertion, deletion in O(log(N)) time. It allows the set and...
10
2338
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. No problem with class MyList<T> : List<T> { }
0
1164
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 converted to HTML and then their source put into the portal modules. Some problems we have run into: - Our current web site is made in Macromedia Dreamweaver. The dreamweaver automatically manages links for you. How can we do that for ibuyspy...
6
2738
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 mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
10
6761
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 large number) have to be removed (say when ToBeRemoved = true). class SomeObj ToBeRemoved be a boolean field end class
1
1223
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 not log error at event log. Is there any method to fix this issue and make the event log generate !!!!
4
2538
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
2152
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. #!usr/local/bin/perl -w use Test::More tests => 5; use Test::Files; use File::Spec; my $logging = "file";
30
37051
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 supplies information about the current Users in the Database. This is accomplished by using the OpenSchema() Method of the Connection Object, which will fill a recordset with varied sets of different Database Schema information. The output of this...
0
8454
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8362
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8560
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8644
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.