设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 956|回复: 2
打印 上一主题 下一主题

[其它] 如何写这个语句

[复制链接]
跳转到指定楼层
1#
发表于 2004-9-17 22:26:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
上次参照了黄海班主的登陆事例.想完成如下的功能:

登陆后,根据不同的登陆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.

请教!!! 谢谢!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2004-9-19 04:08:00 | 只看该作者
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"

      End If

Else

      MsgBox "用户名或密码不正确!", vbCritical

      Exit Sub

      

End If
3#
发表于 2004-9-20 19:54:00 | 只看该作者
endif的位置错了?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-11 22:36 , Processed in 0.080490 second(s), 26 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表