设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 91144|回复: 190
打印 上一主题 下一主题

[Access本身] Access技巧接龙

[复制链接]
1#
发表于 2004-12-3 04:26:00 | 显示全部楼层
  我用的不在列表中的代码,较为方便,用于不同的字段只要改一下表名即可。控件属性中标记为控件名也是表中字段名称,必须统一。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
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-2 12:20 , Processed in 0.079951 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表