主题:[原创]高手帮忙看下哪里错了,急
option compare datebase
Public Function getrs(ByVal strquery As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim conn As ADODB.Connection
On Error GoTo getrs_error
Set conn = CurrentProject.Connection
rs.Open struery, conn, addopenkeyset, adLockOptimistic
Set getrs = rs
getrs_exit:
Set rs = noting
Set conn = noting
Exit Function
getrs_error
MsgBox (Err.Description)
Private Sub Command5_Click()
On Error GoTo err_command5_click
Dim rs As New ADODB.Recordset
Dim str As String
Dim n As Integer
str = "select count(注册表.用户ID) from 注册表 where 注册表.用户名=" & Me.Text1
str = str & " and 注册表.用户密码=" & Me.Text3 & ""
Set rs = getrs(str)
n = rs(0)
If Trim(Me.Text1) = "" Or Is
Null(Me.Text3) Then
MsgBox ("请输入用户名称!")
ElseIf Trim(Me.Text3) = "" Or IsNull(Me.Text3) Then
MsgBox ("请输入用户密码!")
ElseIf n <> 1 Then
MsgBox ("用户密码错误!")
Else: Me.Visible = False
dcmd.OpenForm "主界面"
endlif
exit_command5_click:
Exit Sub
MsgBox (Err.Description)
Resume exit_command_click
End Sub
End Sub
Private Sub Command6_Click()
DoCmd.Quit
End Sub
Private Sub Command7_Click()
dcmd.Beep
End Sub
Private Sub command8_load()
Me.Text1.SetFocus
Me.Text1 = ""
Me.Text3 = ""
End Sub
Public Function getrs(ByVal strquery As String) As ADODB.Recordset
Dim rs As New ADODB.Recordset
Dim conn As ADODB.Connection
On Error GoTo getrs_error
Set conn = CurrentProject.Connection
rs.Open struery, conn, addopenkeyset, adLockOptimistic
Set getrs = rs
getrs_exit:
Set rs = noting
Set conn = noting
Exit Function
getrs_error
MsgBox (Err.Description)
Private Sub Command5_Click()
On Error GoTo err_command5_click
Dim rs As New ADODB.Recordset
Dim str As String
Dim n As Integer
str = "select count(注册表.用户ID) from 注册表 where 注册表.用户名=" & Me.Text1
str = str & " and 注册表.用户密码=" & Me.Text3 & ""
Set rs = getrs(str)
n = rs(0)
If Trim(Me.Text1) = "" Or Is
Null(Me.Text3) Then
MsgBox ("请输入用户名称!")
ElseIf Trim(Me.Text3) = "" Or IsNull(Me.Text3) Then
MsgBox ("请输入用户密码!")
ElseIf n <> 1 Then
MsgBox ("用户密码错误!")
Else: Me.Visible = False
dcmd.OpenForm "主界面"
endlif
exit_command5_click:
Exit Sub
MsgBox (Err.Description)
Resume exit_command_click
End Sub
End Sub
Private Sub Command6_Click()
DoCmd.Quit
End Sub
Private Sub Command7_Click()
dcmd.Beep
End Sub
Private Sub command8_load()
Me.Text1.SetFocus
Me.Text1 = ""
Me.Text3 = ""
End Sub