提示子程序或函数未定义
Private Sub cmdenter_click()
Dim strpassword, strusername As String
Dim flag As Integer
Dim record As ADODB.Recordset
flag = 0
openrecord "select*from 用户登录表", record
Do Until record.EOF
strusername = record("用户名")
strpassword = record("密码")
If UCase(Me.Txtusername.Value) <> UCase(strusername) Then
record.MoveNext
Else
flag = 1
Exit Do
End If
Loop
If flag = 0 Then
MsgBox "该用户名不存在,请重新输入!"
Me.txtpassword = ""
Me.Txtusername = "123"
Me.Txtusername.SetFocus
cmdenter.Enabled = False
Exit Sub
Else
If UCase(Me.txtpassword.Value) <> UCase(strpassword) Then
MsgBox ("密码错误,请重新输入")
Me.txtpassword.Value = ""
Me.txtpassword .SetFocus
cmdenter.Enabled = False
Exit Sub
End If
End If
DoCmd.Close
DoCmd.OpenForm "主界面"
End Sub
Private Sub cmdexit_Click()
On Error GoTo Err_cmdexit_Click
DoCmd.Close
Exit_cmdexit_Click:
Exit Sub
Err_cmdexit_Click:
MsgBox Err.Description
Resume Exit_cmdexit_Click
End Sub
Private Sub Form_Current()
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case Me.ActiveControl.Name
Case "txtusername":
If Me.ActiveControl.Text = "" Or IsNull(Me.ActiveControl.Text) Then
cmdenter.Enabled = False
Exit Sub
Else
If Me.txtpassword.Value = "" Or IsNull(Me.txtpassword.Value) Then
cmdenter.Enabled = False
Exit Sub
End If
End If
Case "txtpassword":
If Me.ActiveControl.Text = "" Or IsNull(Me.ActiveControl.Text) Then
cmdenter.Enabled = False
Exit Sub
Else
If Me.Txtusername.Value = "" Or IsNull(Me.Txtusername.Value) Then
cmdenter.Enabled = False
Exit Sub
End If
End If
Case Else:
Exit Sub
End Select
cmdenter.Enabled = True
Exit Sub
End Sub
Private Sub Form_Open(Cancel As Integer)
cmdenter.Enabled = False
Form.KeyPreview = True
End Sub