| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 407 人关注过本帖
标题:[求助]关于模块的问题!
只看楼主 加入收藏
yw0903
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-5-31
收藏
 问题点数:0 回复次数:0 
[求助]关于模块的问题!
这段代码能否简化一下。其中哪些要放到公共模块中的?谢谢大家了


Private Sub cmdUpdate_Click()
Dim con As New ADODB.Connection
Dim Rs As New Recordset
Dim Sql As String
If txtinfor(0).Text = "" Then
MsgBox "工号不能为空", vbExclamation + vbOKOnly, "提示"
Exit Sub
End If
If txtinfor(1).Text = "" Then
MsgBox "姓名不能为空", vbExclamation + vbOKOnly, "提示"
Exit Sub
End If
con.Open "Provider=SQLOLEDB.1;Password=***;Persist Security Info=True;User ID=***;Initial Catalog=MaxHRSec;Data Source=MAXSF-SQL"
Set Rs = New ADODB.Recordset
Sql = "select empno from AAAAA where empno='" & Trim(txtinfor(0).Text) & "'"
Rs.Open Sql, con, adOpenDynamic, adOpenKeyset
If Not Rs.EOF Then
MsgBox "有重复记录",vbExclamation + vbOKOnly, "提示"
Exit Sub
End If
With Adodc1.Recordset
.Fields(0).Value = txtinfor(0).Text
.Fields(1).Value = txtinfor(1).Text
.Fields(2).Value = txtinfor(2).Text
.Fields(3).Value = txtinfor(3).Text
.Fields(4).Value = txtinfor(4).Text
End With
Adodc1.Recordset.UpdateBatch adAffectAllChapters
MsgBox "添加成功", vbInformation + vbOKOnly, "提示"
Exit Sub
End Sub

搜索更多相关主题的帖子: 模块 
2007-06-05 14:33
快速回复:[求助]关于模块的问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010967 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved