Login 访问-用户跟踪历史系统

Login 访问-用户跟踪历史系统,login,ms-access-2010,history,Login,Ms Access 2010,History,我正在设计一个Access数据库,我想建立一个用户历史跟踪系统 我的目标:保存所有登录和用户操作(登录尝试和搜索) 这样,我得到了1张表格和2张表格: 所有用户注册登录对话框的登录窗体 搜索标准表格标准表格 包含以下字段的历史记录表WO:日期、用户、源表、研究历史记录、注释用户活动跟踪器 让我们首先关注登录系统: 如何在每次登录成功时在评论中将操作注册为“登录成功”,并在相反情况下尝试登录? 例如有 2015年3月24日-用户1-登录对话框-登录成功 2015年3月24日-用户2-登录对话框--

我正在设计一个Access数据库,我想建立一个用户历史跟踪系统

我的目标:保存所有登录和用户操作(登录尝试和搜索)

这样,我得到了1张表格和2张表格:

  • 所有用户注册登录对话框的登录窗体
  • 搜索标准表格标准表格
  • 包含以下字段的历史记录表WO:日期、用户、源表、研究历史记录、注释用户活动跟踪器
  • 让我们首先关注登录系统:

    如何在每次登录成功时在评论中将操作注册为“登录成功”,并在相反情况下尝试登录?

    例如有 2015年3月24日-用户1-登录对话框-登录成功 2015年3月24日-用户2-登录对话框--尝试登录 2015年3月24日-用户1-导航表-注销

    以下是我最初编写的代码:

    Const cDQ As String = """"
    
    Public Function Loginwrong()
    
    'Set the sql equality
    
    Dim strsql As String
    
    strsql = "INSERT INTO" & "[User activity tracker](Date, User, Soucetable, Researchhistory, Comments)" & _
    "VALUES (Now()," & cDQ & frm.RecordSource.login & cDQ & "," & frm.RecordSource & cDQ & ", Attempt login)"
    
    DoCmd.RunSQL strsql
    
    End Function
    
    面对它,我尝试了另一种方法:

    Public Function Loginyes()
    
    'Set the sql equality
    
    Dim strsql As String
    
    strsql = "INSERT INTO " _
               & "[User Activity Tracker] (Date, User, SourceTable, " _
               & " ResearchHistory, Comments) " _
               & "VALUES (Now()," _
               & cDQ & Environ("login") & cDQ & ", " _
               & cDQ & frm.RecordSource & cDQ & ", " _
               & cDQ & "," _
               & cDQ & "Login success" & cDQ & ")"
            'View evaluated statement in Immediate window.
            Debug.Print strsql
            DoCmd.SetWarnings False
            DoCmd.RunSQL strsql
            DoCmd.SetWarnings True
    
    DoCmd.RunSQL strsql
    

    你有什么见解吗?评论?想法?

    *我终于找到了这个函数的解决方案

    只是粘贴它以防其他人需要它:

    Public Function Loginwrong()
    
    'Define the elements dimensions
    Dim frm As Form
    Dim strsql As String
    
    'Set the equality to have the current form used taken into account
    Set frm = Screen.ActiveForm
    
    
    'Use it to find values of the given controls
    strsql = "INSERT INTO [User Activity]([Date], [User], SourceTable, Comments)" _
    & "" & "VALUES(Now()," & "'" & frm.[login].Value & "','" & frm.Name & "', 'Wrong Password'" & "'" & frm.[passwordlogin].Value & "');"
    
    
            'View evaluated statement in Immediate window.
            Debug.Print strsql
            DoCmd.SetWarnings False
            DoCmd.RunSQL strsql
            DoCmd.SetWarnings True
    
    End Function
    

    我在第一次编码中忘记了添加“”以便将其视为文本答案。*

    欢迎使用堆栈溢出!不幸的是,这是一个英语网站,因此所有问题和答案都应该是英语的。好的,对不起,我会修改它以符合规则:)没关系,我确实发现了问题。谢谢