joeythelips
IS-IT--Management
Hi,
I have an access application (2000) which uses vba to import excel files and write this data to an oracle database (8.1.7).
The tables are linked using a odbc link from access to oracle.
When a user opens the application, he/she is asked to verify the odbc link.
What i want to do is capture the user name in my logfile table in oracle.
Currently my logfile table captures the imported filename, the current time, and the number of unique records.
Please see my code below for how i do this. The new field name in the logfile table is called username.
I would really appreciate help on this.
Regards,
Joe
Sub Logfile(READFILENAME)
Dim dbs As Database
Dim rs(1 To 3) As Recordset
Dim i As Integer
Const conSource = "LogFile"
On Error GoTo ErrHandler
Set dbs = OpenDatabase("P:\FileImporter.mdb"
Set rs(1) = dbs.OpenRecordset("SELECT * FROM ReadingsBills"
Set rs(2) = dbs.OpenRecordset("SELECT DISTINCT [Meter Ref#] FROM readingsBills"
Set rs(3) = dbs.OpenRecordset("SELECT * FROM LogFile"
For i = 1 To 2
If Not rs(i).EOF Then
rs(i).MoveLast
End If
Next
With rs(3)
.AddNew
.Fields("FileName"
= "RE" & READFILENAME
.Fields("TimeDateStamp"
= Now()
.Fields("TotalRecordCount"
= rs(1).RecordCount
.Fields("UniqueRecordCount"
= rs(2).RecordCount
.Update
End With
For i = 1 To 3
rs(i).Close
Set rs(i) = Nothing
Next
Exit Sub
ErrHandler:
Set rs(1) = Nothing
Set rs(2) = Nothing
Set rs(3) = Nothing
Err.Raise Err.Number, conSource, Err.Description
End Sub
I have an access application (2000) which uses vba to import excel files and write this data to an oracle database (8.1.7).
The tables are linked using a odbc link from access to oracle.
When a user opens the application, he/she is asked to verify the odbc link.
What i want to do is capture the user name in my logfile table in oracle.
Currently my logfile table captures the imported filename, the current time, and the number of unique records.
Please see my code below for how i do this. The new field name in the logfile table is called username.
I would really appreciate help on this.
Regards,
Joe
Sub Logfile(READFILENAME)
Dim dbs As Database
Dim rs(1 To 3) As Recordset
Dim i As Integer
Const conSource = "LogFile"
On Error GoTo ErrHandler
Set dbs = OpenDatabase("P:\FileImporter.mdb"
Set rs(1) = dbs.OpenRecordset("SELECT * FROM ReadingsBills"
Set rs(2) = dbs.OpenRecordset("SELECT DISTINCT [Meter Ref#] FROM readingsBills"
Set rs(3) = dbs.OpenRecordset("SELECT * FROM LogFile"
For i = 1 To 2
If Not rs(i).EOF Then
rs(i).MoveLast
End If
Next
With rs(3)
.AddNew
.Fields("FileName"
.Fields("TimeDateStamp"
.Fields("TotalRecordCount"
.Fields("UniqueRecordCount"
.Update
End With
For i = 1 To 3
rs(i).Close
Set rs(i) = Nothing
Next
Exit Sub
ErrHandler:
Set rs(1) = Nothing
Set rs(2) = Nothing
Set rs(3) = Nothing
Err.Raise Err.Number, conSource, Err.Description
End Sub