在access中设计一个登陆界面,运行时提示“除非控件获得焦点,否则你不能应用该控件的属性”,代码如下:
PrivateSubForm_Load()Text1.SetFocusText1.Text=""Text2.SetFocusText2.Text=""EndSubPriv...
Private Sub Form_Load()
Text1.SetFocus
Text1.Text = ""
Text2.SetFocus
Text2.Text = ""
End Sub
Private Sub Command1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "用户名或密码不能为空"
Else
If Text1.Text = "admin123" And Text2.Text = "123" Then
MsgBox "欢迎进入系统"
Else
MsgBox "用户名或密码不正确"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Text2.SetFocus
End If
End If
End Sub
还需要怎么改动,才能在access中运行呢? 展开
Text1.SetFocus
Text1.Text = ""
Text2.SetFocus
Text2.Text = ""
End Sub
Private Sub Command1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "用户名或密码不能为空"
Else
If Text1.Text = "admin123" And Text2.Text = "123" Then
MsgBox "欢迎进入系统"
Else
MsgBox "用户名或密码不正确"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Text2.SetFocus
End If
End If
End Sub
还需要怎么改动,才能在access中运行呢? 展开
1个回答
展开全部
把 .text 改为 .value,或者直接这样text1=“”...
.text属性要求控件获得焦点的...
Private Sub Form_Load()
text1=""
text2=""
End Sub
Private Sub Command1_Click()
If Text1 = "" And Text2 = "" Then
MsgBox "用户名或密码不能为空"
Else
If Text1 = "admin123" And Text2 = "123" Then
MsgBox "欢迎进入系统"
Else
MsgBox "用户名或密码不正确"
Text1 = ""
Text2 = ""
Text1.SetFocus
End If
End If
End Sub
祝你成功!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询