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

OFFICE 2019 ACCESS遍历窗口文本框和组合框

时 间:2020-01-26 23:06:09
作 者:   ID:48957  城市:昆山
摘 要:OFFICE 2019 ACCESS遍历窗口文本框和组合框
正 文:

OFFICE 2019 ACCESS遍历窗口文本框和组合框

    If MsgBox("您确定要修改当权记录内容吗?", vbYesNo, "提醒") = vbYes Then

        Dim OldStr As String
        Dim NewStr As String
        Dim Ctl As Access.Control
''        Dim Ctl As Access.TextBox
''        Dim CtlCombo As Access.ComboBox
'        On Error Resume Next
        For Each Ctl In Me.Form.Controls '遍历控件汇总新旧数据进行对比,若一致则表明未修改,则不用进行后续修改程序
            If Ctl.Name <> "父阶物料" Then '因为父阶物料属临时文本框,数据表中并无该字段,故不用考虑对吧
                If Ctl.ControlType = 109 or Ctl.ControlType = 111 Then '109代表文本框,111代表组合框
                    If Nz(OldStr, "") = "" Then
                    
                        OldStr = Ctl.Value
                        NewStr = DLookup(Ctl.Name, "My_ProductTable", "产品代码='" & Me.产品代码 & "'")
                    Else
                        OldStr = OldStr & "|" & Ctl.Value
                        NewStr = NewStr & "|" & DLookup(Ctl.Name, "My_ProductTable", "产品代码='" & Me.产品代码 & "'")
                    End If
                End If
            End If
        Next
        
'        For Each CtlCombo In Me.Form.Controls
'            If Nz(OldStr, "") = "" Then
'                OldStr = CtlCombo.Value
'                NewStr = DLookup(CtlCombo.Name, "My_ProductTable", "产品代码='" & Me.产品代码 & "'")
'            Else
'                OldStr = OldStr & "|" & CtlCombo.Value
'                NewStr = NewStr & "|" & DLookup(CtlCombo.Name, "My_ProductTable", "产品代码='" & Me.产品代码 & "'")
'            End If
'        Next
        
        Debug.Print OldStr
        Debug.Print NewStr
        
        If OldStr = NewStr Then MsgBox "您并未修改当前记录,请确认!", , "提醒": Exit Sub
        DoCmd.OpenForm "frmMy_KeyPassWord", OpenArgs:="ChangeProduct" & "|" & Me.产品代码: Exit Sub
    Else
        Exit Sub
    End If

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

常见问答:

技术分类:

相关资源:

专栏作家

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