Access VBA

css navigation by Css3Menu.com

Procedure History

Our system contains lot of sensitive information. I built a “behind the scenes” table that shows what reports have been generated, whose information is on it, and who created.

Only the manager and administrator know this report exists.

Sub ReportHistoryUpdate(RptName As String, PartID As String, RptType As Long)
    Dim RptUpd      As String
    Dim Quotes      As String
    On Error GoTo ErrorHandle
    Quotes = Chr(34)
    gbl_NuserID = Environ("USERNAME")
    gbl_Machine = Environ("COMPUTERNAME")
    RptUpd = "INSERT INTO Report_History ( ReportName, ParticipantID, ReportDate, UserID, MachineID, ReportType )"
    RptUpd = RptUpd & " VALUES (" & Quotes & RptName & Quotes & "," _
        & Quotes & PartID & Quotes & ",#" & Now() & "#," & _
       Quotes & gbl_NuserID & Quotes & "," & Quotes & gbl_Machine & Quotes & "," & RptType & ");"
    DoCmd.SetWarnings False
    DoCmd.RunSQL RptUpd    'Update history if completed
    DoCmd.SetWarnings True
    Exit Sub
ErrorHandle:
    MsgBox "Please report error " & Err.Number & vbLf & Err.Description, vbCritical, "Oops!"
End Sub

Resulting SQL statement is:
INSERT INTO Report_History ( ReportName, ParticipantID, ReportDate, UserID, MachineID, ReportType ) VALUES ("Assessment_Results","K35045D6285800",#06/17/2007 19:48:48#,"Alan","ARB",3);

© 2007-2024

Updated:  04/17/2024 12:26
This page added:  17 June 2007