設(shè)為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊(cè)

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 27551|回復(fù): 128
打印 上一主題 下一主題

[宏/菜單/工具欄] ACCESS組合框新用法

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2008-9-14 19:34:08 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
公司ERP項(xiàng)目使用的是某友軟件公司的XXX,錄入數(shù)據(jù)時(shí)有個(gè)參照功能(可以錄入編碼,也可以錄入物料名稱……)?戳撕蒙刀,能不能將ACCESS的組合框動(dòng)動(dòng)手腳,模擬一下人家的效果?仔細(xì)查看Combobox的屬性,見有個(gè)ColumnWidths屬性,靈感來了…… 干脆多顯示幾列(包括物料編碼,物料名稱,自定義的“快速輸入代碼”列),LostFocus時(shí)再將其他不必要的列隱藏。      具體demo參見附件。
  由于我的機(jī)器上沒有安裝ACCESS2003,demo數(shù)據(jù)庫使用ACCESS2007做的,然后存了一個(gè)Access2003gesi ,不知在2003能不能用.   
小弟初學(xué)ACCESS,希望各位多多指教。
游客,如果您要查看本帖隱藏內(nèi)容請(qǐng)回復(fù)

本帖子中包含更多資源

您需要 登錄 才可以下載或查看,沒有帳號(hào)?注冊(cè)

x

評(píng)分

參與人數(shù) 1經(jīng)驗(yàn) +3 收起 理由
tanhong + 3 原創(chuàng)內(nèi)容

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享分享 分享淘帖 訂閱訂閱
2#
發(fā)表于 2008-9-14 20:01:12 | 只看該作者
謝謝分享[:26]
3#
發(fā)表于 2008-9-14 21:54:29 | 只看該作者
這個(gè)貌似可以用組合框按鈕向?qū)Ц愣ā?/td>
4#
 樓主| 發(fā)表于 2008-9-14 23:09:16 | 只看該作者

補(bǔ)充一下

發(fā)帖時(shí)可能沒有表達(dá)清楚。
最終組合框的效果為:存儲(chǔ)A列,顯示B列,輸入C列。
5#
發(fā)表于 2008-9-14 23:27:52 | 只看該作者
謝謝分享,,,,先看看,,,[:50]

點(diǎn)擊這里給我發(fā)消息

6#
發(fā)表于 2008-9-15 00:18:44 | 只看該作者
謝謝分享,大家所見略同,我也是使用這種方法, 不過寫成了通用函數(shù),方便設(shè)置不同列數(shù) 不同欄寬的組合框.
'===============================================================================
'-函數(shù)名稱:         gt_SetComboColumnWidth
'-功能描述:         設(shè)置組合框欄位寬度,進(jìn)入時(shí)可按編碼錄入,離開時(shí)可顯示名稱
'-輸入?yún)?shù)說明:     參數(shù)1:rctr Control 控件對(duì)象
'                   參數(shù)2:rstrColumnWidths String 欄位寬度
'-返回參數(shù)說明:     無
'-使用語法示例:     gt_SetComboColumnWidth cboCust,"3;2;4"
'-參考:
'-使用注意:         只適用Label TextBox CommandButton ComboBox OptionButton CheckBox
'-兼容性:           97,2000,XP,2003 compatible
'-作者:             王宇虹,改進(jìn):王宇虹
'-更新日期:        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


'===============================================================================-----天鳴科技--->>>>>>>>
'-函數(shù)名稱:         gt_SetCboEnterEvent
'-功能描述:         設(shè)置組合框的進(jìn)入事件
'-輸入?yún)?shù):         參數(shù)1:rctrComboBox String 組合框控件
'                   可選參數(shù)2:rintType Integer 方式
'                   可選參數(shù)3:rstrTemp String 其它參數(shù)
'-返回參數(shù):         無
'-使用示例:         gt_SetCboEnterEvent cboCust,0
'-相關(guān)調(diào)用:         無
'-使用注意:         可設(shè)置是否自動(dòng)彈出組合框,還是沒有內(nèi)容才彈出組合框
'-兼 容 性:         97,2000,XP,2003 compatible
'-參考資料:
'-作    者:         王宇虹  修改:王宇虹
'-創(chuàng)建日期;         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


'===============================================================================-----天鳴科技--->>>>>>>>
'-函數(shù)名稱:         gt_SetCboExitEvent
'-功能描述:         設(shè)置組合框的離開事件
'-輸入?yún)?shù):         參數(shù)1:rctrComboBox String 組合框控件
'                   可選參數(shù)2:rintType Integer 方式
'                   可選參數(shù)3:rstrTemp String 其它參數(shù)
'-返回參數(shù):         無
'-使用示例:         gt_SetCboExitEvent cboCust,0
'-相關(guān)調(diào)用:         無
'-使用注意:
'-兼 容 性:         97,2000,XP,2003 compatible
'-參考資料:
'-作    者:         王宇虹  修改:王宇虹
'-創(chuàng)建日期;         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#
發(fā)表于 2008-9-15 07:54:43 | 只看該作者
看看一下
8#
 樓主| 發(fā)表于 2008-9-15 08:44:08 | 只看該作者

高,實(shí)在是高!

哇,站長這個(gè)實(shí)在是方便,全面。學(xué)習(xí)了。謝謝,順便說一下。俺去年買了各位領(lǐng)導(dǎo)的《Access開發(fā)答疑200問》,學(xué)到不少東西。現(xiàn)在已經(jīng)開發(fā)了幾個(gè)小型數(shù)據(jù)庫。效果還不錯(cuò)。謝謝! 確實(shí)是好書!
9#
發(fā)表于 2008-9-15 09:41:10 | 只看該作者
謝謝 fd901028 好實(shí)例!
10#
發(fā)表于 2008-9-15 11:23:41 | 只看該作者
好東西怎么發(fā)到灌水區(qū)了.
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國 ( 粵ICP備10043721號(hào)-1 )  

GMT+8, 2024-10-23 08:39 , Processed in 0.096377 second(s), 36 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表