|
我把权限表和系统窗体表合成一个权限表,字段有 用户名,窗体名称,窗体ID,权限,在模块代码中如下,却执行后没有反应
Option Compare Database
Option Explicit
Public yonghuming As String
Function OpenForm(FormID As Integer)
On Error GoTo Err_OpenForm
Dim i As Integer
Dim STemp As String
Dim Rs1 As ADODB.Recordset
Set Rs1 = New ADODB.Recordset
STemp = "select * from 权限表"
Rs1.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockBatchOptimistic
Dim blnOpen As Boolean
Dim FormName As String
blnOpen = False
If Rs1.RecordCount < 1 Then
blnOpen = False
Else
Rs1.MoveFirst
For i = 1 To Rs1.RecordCount
If (Rs1("用户名") = yonghuming And Rs1("窗体ID") = FormID And Rs1("权限") = True) Then
blnOpen = True
FormName = Rs1("窗体名称")
Else
Rs1.MoveNext
End If
Next i
End If
If (blnOpen = False) Then
MsgBox "你没有权限使用" & "“" & FormName & "”窗体", vbCritical, "提示!"
Else
DoCmd.OpenForm FormName, acNormal, , , , acWindowNormal
End If
Set Rs1 = Nothing
Exit Function
Err_OpenForm
Set Rs1 = Nothing
MsgBox Err.Description, vbOKOnly, "窗体打开错误"
End Function
为什么,我是新手,请各位指教 |
|