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

问题描述

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

登录表单代码为:

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 (将#修改为@)