Access 2010-调试登录屏幕代码 [英] Access 2010- Debugging Login Screen Code
问题描述
我在登录表单的OnClick事件中有以下代码。现在我想知道关闭应用程序的取消按钮的代码是什么?
I have the following code in the OnClick event of my Login form. Now I was wondering what the code would be for the Cancel button that would close the application?
Private Sub cmdLogin_Click()
Private Sub cmdLogin_Click()
Dim strWhere As String
如果IsNull(Me.txtUserName)或IsNull(Me.txtPassword)则为
  MsgBox"您必须输入用户名和密码。"
否则
  strWhere =" UserName ='" &安培; Me.txtUserName& "'和' &安培; _
            " Password ='" &安培; Me.txtPassword& "'"
 如果DCount("*","qry_employee_passwords",strWhere)= 0则为
    MsgBox"不正确的用户名或密码"
 否则
    DoCmd.Close acForm,Me.Name
    DoCmd.OpenForm" frm_main_menu"
 结束如果
结束如果
结束子
Dim strWhere As String
If IsNull(Me.txtUserName) Or IsNull(Me.txtPassword) Then
MsgBox "You must enter a user name and password."
Else
strWhere = "UserName = '" & Me.txtUserName & "' And " & _
"Password = '" & Me.txtPassword & "'"
If DCount("*", "qry_employee_passwords", strWhere) = 0 Then
MsgBox "Incorrect UserName or Password"
Else
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frm_main_menu"
End If
End If
End Sub
Steven Schuyler Berkeley,California USA
Steven Schuyler Berkeley, California USA
推荐答案
我用
Function AP_Save() As Boolean Dim StrMsg As String Dim iResponse As Integer AP_Save = True With Screen.ActiveForm If .Dirty = True Then StrMsg = "Save Changes?" & Chr(10) StrMsg = StrMsg & "Yes to Save, No to Undo or Cancel to Edit Current Record." iResponse = MsgBox(StrMsg, vbQuestion + vbYesNoCancel, "Save Record?") Select Case iResponse Case vbYes: DoCmd.Save .Refresh Case vbNo: .Undo Case vbCancel: AP_Save = False End Select End If End WithEnd Function
这篇关于Access 2010-调试登录屏幕代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!