Set rst = CurrentDb.OpenRecordset("SELECT role" & _
" FROM EMP " & _
" WHERE id =" & Chr(34) & id & Chr(34))
If rst.Fields(role) = "admin" Then
cmdConnecterPrivilege.Visible = True
Else
cmdConnecterPrivilege.Visible = False
End If
我做错了什么?谢谢!我想看看这名员工是否是管理员
答案 0 :(得分:0)
您需要正确的语法,其中包括:
If rst.Fields("role") = "admin"
If rst("role") = "admin"
If rst!role = "admin"
但是你可以使用一个代码行完成这个简单的任务:
cmdConnecterPrivilege.Visible = (Nz(DLookup("role", "EMP", "ID = '" & id & "'")) = "admin")