Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-窗体/数据页

不在列表中的代码

时 间:2007-10-27 12:18:47
作 者:竹笛   ID:8  城市:上海  QQ:2851379730点击这里给张志发消息
摘 要:不在列表中的代码
正 文:

转自OFFICE中国 skylark
我用的不在列表中的代码,较为方便,用于不同的字段只要改一下表名即可。

控件属性中标记为控件名也是表中字段名称,必须统一。

Private Sub 材料_NotInList(NewData As String, Response As Integer)
Dim Rst As DAO.Recordset
Dim strName As String
Dim strMsg As String
strName = Me.ActiveControl.Tag
strMsg = "'" & NewData & "' is not an available '" & strName & "'"
strMsg = strMsg & "Do you want to associate the new Name to the current DLSAF?"
strMsg = strMsg & " Click Yes to link or No to re-type it."

Response = acDataErrContinue
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbYes Then
Set Rst = CurrentDb.OpenRecordset("材料表")
Rst.AddNew
Rst(strName) = NewData
Rst.Update
Rst.Close
Set Rst = Nothing
Me.Controls.Item(strName) = NewData
Me.Controls.Item(strName).Requery
Else
Me.Controls.Item(strName).Undo
End If
End Sub

Access软件网QQ交流群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助