微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

根据登录表单将文本框设置为只读

如何解决根据登录表单将文本框设置为只读

在我的访问数据库中,我有成功登录尝试后下一次打开的登录表单,但是现在我需要进行一次修改,但我不知道该怎么做: 只有两个用户使用此数据库,并且都使用相同的表单输入数据,但是根据用户,表单中的某些文本框需要只读或隐藏,请帮助我实现此目的。

登录表单代码为:

Option Compare Database
Option Explicit

Private Sub btnlogin_Click()
    Dim RS As Recordset
    Set RS = CurrentDb.OpenRecordset("logintable",dbOpenSnapshot,dbReadOnly)
    RS.FindFirst "UserName='" & Me.txtUsername & "'"

    If RS.NoMatch = True Then
        Me.lblwronguser.Visible = True
        Me.txtUsername.SetFocus
        Exit Sub
    End If
    Me.lblwronguser.Visible = False

    If RS!Password <> Nz(Me.txtPassword,"") Then
        Me.lblwrongpassword.Visible = True
        Me.txtPassword.SetFocus
    Exit Sub
    End If
    Me.lblwrongpassword.Visible = False
    DoCmd.Close acForm,"Login screen"
    DoCmd.OpenForm "Main Menu"
End Sub

并且我想要介于两者之间的内容

If Me.txtPassword = "trial" Then
    DoCmd.Close acForm,"Login screen"
    DoCmd.OpenForm "frmwhatdates"
    Form!frmwhatdates!cmdfilter.Visible = False
    Exit Sub
End If

,但执行后会显示错误

 "Runtime Error 2467 The expression you entered refers to an object that is closed or doesn't exist"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。