|
上次参照了黄海班主的登陆事例.想完成如下的功能:
登陆后,根据不同的登陆ID,来决定打开不同的窗体.
黄海老大的原格式为:
Private Sub cmdOK_Click()
If IsNull(Me.cboUserName) Then
MsgBox "请输入您的用户名!", vbQuestion
Exit Sub
End If
If login = True Then
DoCmd.Close acForm, "登陆背景"
Me.TimerInterval = 0
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "控制台"
Else
MsgBox "用户名或密码不正确!", vbCritical
Exit Sub
End If
End Sub
我更改后为: 其中admin是指为以admin的名义登陆.
Private Sub cmdOK_Click()
Dim nm As String
If IsNull(Me.cboUserName) Then
MsgBox "请输入您的用户名!", vbQuestion
Exit Sub
End If
If login = True Then
nm = Me.cboUserName.Value
If nm = "admin" Then
DoCmd.Close acForm, "登陆背景"
Me.TimerInterval = 0
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "主要控制模板"
ElseIf nm <> "admin" Then
DoCmd.Close acForm, "登陆背景"
Me.TimerInterval = 0
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "form1"
Else
MsgBox "用户名或密码不正确!", vbCritical
Exit Sub
End If
End If
End Sub
可是出来的多是 form1.
请教!!! 谢谢! |
|