为什么在“修改密码”窗体中的“用户名”文本中不显示
Option ExplicitDim cnt As Integer
Public guest As String
Public username As String
Private Sub Command1_Click()
Dim sql As String
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim guest As String
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\database.mdb"
If Text1.Text = "" Then
MsgBox "用户名不能为空,请重新输入!", vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
Else
sql = "select * from yonghu where username='" & Text1.Text & "'"
rs.Open sql, cn, adOpenKeyset, adLockPessimistic
If rs.EOF = True Then
MsgBox "没有这个用户,请重新输入!", vbOKOnly, "提示"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Else
username = Text1.Text
End If
If Text1.Text = "guest" Then
MsgBox "非管理员用户,有些功能您不能用,为此感到抱歉", vbOKOnly + vbExclamation, "提示"
MDIForm1.AddUser.Enabled = False
MDIForm1.DeleteUser.Enabled = False
MDIForm1.StudentOut.Enabled = False
Else
End If
If Trim(rs.Fields(1)) = Trim(Text2.Text) Then
Unload Me
MDIForm1.Show
Exit Sub
Else
MsgBox "密码错误,请重新输入", vbOKOnly + vbCritical, "提示"
Text2.Text = ""
Text2.SetFocus
End If
End If
cnt = cnt + 1
If cnt = 3 Then
MsgBox "三次都输入不正确,请你自觉退出"
Unload Me
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
cnt = 0
End Sub
这是登录窗体的代码。。。。。。。。。
Private Sub Command1_Click()
Dim sql As String
Dim cn As New ADODB.Connection
Dim rs_mima As New ADODB.Recordset
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\database.mdb"
If Trim(Text2.Text) <> Trim(Text3.Text) Then
MsgBox "两次密码不一致,请重新输入!", vbOKOnly + vbExclamation, "提示"
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
Exit Sub
Else
sql = "select * from yonghu "
rs_mima.Open sql, cn, adOpenKeyset, adLockPessimistic
rs_mima.Fields(1) = Text2.Text
rs_mima.Update
MsgBox "密码修改成功"
Unload Me
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
username = frmLogin.Text1.Text
username = Text1.Text
End Sub
这是修改密码的代码.
我想在攸密码的窗体中一加载窗体就在“用户名”的文本中显示我登录时的用户名,为什么不能实现呢?不请各位高手指点指点。