设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[宏/菜单/工具栏] ACCESS组合框新用法

[复制链接]
跳转到指定楼层
1#
发表于 2008-9-14 19:34:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
公司ERP项目使用的是某友软件公司的XXX,录入数据时有个参照功能(可以录入编码,也可以录入物料名称……)。看了好生嫉妒,能不能将ACCESS的组合框动动手脚,模拟一下人家的效果?仔细查看Combobox的属性,见有个ColumnWidths属性,灵感来了…… 干脆多显示几列(包括物料编码,物料名称,自定义的“快速输入代码”列),LostFocus时再将其他不必要的列隐藏。      具体demo参见附件。
  由于我的机器上没有安装ACCESS2003,demo数据库使用ACCESS2007做的,然后存了一个Access2003gesi ,不知在2003能不能用.   
小弟初学ACCESS,希望各位多多指教。
游客,如果您要查看本帖隐藏内容请回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

评分

参与人数 1经验 +3 收起 理由
tanhong + 3 原创内容

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享分享 分享淘帖 订阅订阅
2#
发表于 2008-9-14 20:01:12 | 只看该作者
谢谢分享[:26]
3#
发表于 2008-9-14 21:54:29 | 只看该作者
这个貌似可以用组合框按钮向导搞定。
4#
 楼主| 发表于 2008-9-14 23:09:16 | 只看该作者

补充一下

发帖时可能没有表达清楚。
最终组合框的效果为:存储A列,显示B列,输入C列。
5#
发表于 2008-9-14 23:27:52 | 只看该作者
谢谢分享,,,,先看看,,,[:50]

点击这里给我发消息

6#
发表于 2008-9-15 00:18:44 | 只看该作者
谢谢分享,大家所见略同,我也是使用这种方法, 不过写成了通用函数,方便设置不同列数 不同栏宽的组合框.
'===============================================================================
'-函数名称:         gt_SetComboColumnWidth
'-功能描述:         设置组合框栏位宽度,进入时可按编码录入,离开时可显示名称
'-输入参数说明:     参数1:rctr Control 控件对象
'                   参数2:rstrColumnWidths String 栏位宽度
'-返回参数说明:     无
'-使用语法示例:     gt_SetComboColumnWidth cboCust,"3;2;4"
'-参考:
'-使用注意:         只适用Label TextBox CommandButton ComboBox OptionButton CheckBox
'-兼容性:           97,2000,XP,2003 compatible
'-作者:             王宇虹,改进:王宇虹
'-更新日期:        2004-08-24
'===============================================================================
Public Function gt_SetComboColumnWidth(rctr As Control, rstrColumnWidths As String)
    On Error Resume Next
    If TypeOf rctr Is ComboBox Then
        rctr.ColumnWidths = rstrColumnWidths
        ' rctr.RowSource = rctr.RowSource
        ' rctr.Requery
    End If
End Function


'===============================================================================-----天鸣科技--->>>>>>>>
'-函数名称:         gt_SetCboEnterEvent
'-功能描述:         设置组合框的进入事件
'-输入参数:         参数1:rctrComboBox String 组合框控件
'                   可选参数2:rintType Integer 方式
'                   可选参数3:rstrTemp String 其它参数
'-返回参数:         无
'-使用示例:         gt_SetCboEnterEvent cboCust,0
'-相关调用:         无
'-使用注意:         可设置是否自动弹出组合框,还是没有内容才弹出组合框
'-兼 容 性:         97,2000,XP,2003 compatible
'-参考资料:
'-作    者:         王宇虹  修改:王宇虹
'-创建日期;         2002-08-26  更新日期: 2002-08-28 ,2002-11-15
'-图    解:
'===============================================================================--<>>>>>

Public Function gt_SetCboEnterEvent(Optional rctrComboBox As Control, Optional rintType As Integer = 0, Optional rstrTemp As String)
    Dim blnCancel As Boolean
    Dim frm As Form
    On Error Resume Next

    If TypeOf rctrComboBox.Parent Is Form Then
        Set frm = rctrComboBox.Parent
    Else
        If TypeOf rctrComboBox.Parent.Parent Is Form Then
            Set frm = rctrComboBox.Parent.Parent
        Else
            If TypeOf rctrComboBox.Parent.Parent.Parent Is Form Then
                Set frm = rctrComboBox.Parent.Parent.Parent
            Else
                Exit Function
            End If

        End If
    End If
    If frm Is Nothing Then Exit Function
    If frm.CurrentView = 1 Then
        If Nz(gt_GetParaItem("PopupWindow", rctrComboBox.Tag)) <> "" Or Nz(gt_GetParaItem("DropWindow", rctrComboBox.Tag)) <> "" Then


            frm.cmdOpenSelWindow.Tag = frm.ActiveControl.name
            frm.cmdOpenSelWindow.Left = frm.ActiveControl.Left + frm.ActiveControl.Width + 10
            frm.cmdOpenSelWindow.Top = frm.ActiveControl.Top

            If frm.AllowEdits = False Or frm.Controls(frm.cmdOpenSelWindow.Tag).Enabled = False Or frm.Controls(frm.cmdOpenSelWindow.Tag).Locked = True Then   '
                If frm.cmdOpenSelWindow.Object.Enabled = True Then
                    frm.cmdOpenSelWindow.Object.Enabled = False

                End If
                If frm.cmdOpenSelWindow.Visible = True Then
                    frm.cmdOpenSelWindow.Visible = False
                End If
            Else
                If frm.cmdOpenSelWindow.Object.Enabled = False Then
                    frm.cmdOpenSelWindow.Object.Enabled = True

                End If
                If frm.cmdOpenSelWindow.Visible = False Then
                    frm.cmdOpenSelWindow.Visible = True
                End If
            End If

        End If

    End If
    If Nz(rctrComboBox.ControlSource) <> "" Then
        If frm.AllowEdits = False Or rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
            blnCancel = True
        End If
    Else
        If rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
            blnCancel = True
        End If
    End If
    If blnCancel Then Exit Function
    If Nz(gt_GetParaItem("ComboStyle", rctrComboBox.Tag)) = "Autocbo" Then    'InStr(rctrComboBox.Tag, "autocbo") > 0
        gt_SetComboColumnWidth rctrComboBox, rstrTemp
    End If

    Select Case rintType
    Case 2
        gt_ComboAutoExpand rctrComboBox, True
    Case 1
        gt_ComboAutoExpand rctrComboBox, False
    Case 0

    End Select

End Function


'===============================================================================-----天鸣科技--->>>>>>>>
'-函数名称:         gt_SetCboExitEvent
'-功能描述:         设置组合框的离开事件
'-输入参数:         参数1:rctrComboBox String 组合框控件
'                   可选参数2:rintType Integer 方式
'                   可选参数3:rstrTemp String 其它参数
'-返回参数:         无
'-使用示例:         gt_SetCboExitEvent cboCust,0
'-相关调用:         无
'-使用注意:
'-兼 容 性:         97,2000,XP,2003 compatible
'-参考资料:
'-作    者:         王宇虹  修改:王宇虹
'-创建日期;         2002-08-26  更新日期: 2002-08-28 ,2002-11-15
'-图    解:
'===============================================================================--<>>>>>
Public Function gt_SetCboExitEvent(Optional rctrComboBox As Control, Optional rintType As Integer = 0, Optional rstrTemp As String)
    Dim blnCancel As Boolean
    Dim frm As Form
    On Error Resume Next

    If TypeOf rctrComboBox.Parent Is Form Then
        Set frm = rctrComboBox.Parent
    Else
        If TypeOf rctrComboBox.Parent.Parent Is Form Then
            Set frm = rctrComboBox.Parent.Parent
        Else
            If TypeOf rctrComboBox.Parent.Parent.Parent Is Form Then
                Set frm = rctrComboBox.Parent.Parent.Parent
            Else
                Exit Function
            End If
        End If
    End If
    If frm Is Nothing Then Exit Function
    If Nz(rctrComboBox.ControlSource) <> "" Then
        If frm.AllowEdits = False Or rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
            blnCancel = True
        End If
    Else
        If rctrComboBox.Enabled = False Or rctrComboBox.Locked = True Then
            blnCancel = True
        End If
    End If
    If blnCancel Then Exit Function
    If Nz(gt_GetParaItem("ComboStyle", rctrComboBox.Tag)) = "Autocbo" Then    'InStr(rctrComboBox.Tag, "autocbo") > 0
        gt_SetComboColumnWidth rctrComboBox, rstrTemp
    End If
End Function
7#
发表于 2008-9-15 07:54:43 | 只看该作者
看看一下
8#
 楼主| 发表于 2008-9-15 08:44:08 | 只看该作者

高,实在是高!

哇,站长这个实在是方便,全面。学习了。谢谢,顺便说一下。俺去年买了各位领导的《Access开发答疑200问》,学到不少东西。现在已经开发了几个小型数据库。效果还不错。谢谢! 确实是好书!
9#
发表于 2008-9-15 09:41:10 | 只看该作者
谢谢 fd901028 好实例!
10#
发表于 2008-9-15 11:23:41 | 只看该作者
好东西怎么发到灌水区了.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 04:15 , Processed in 0.096201 second(s), 36 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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