Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

[5分]各位好,我想实现ACCESS中的录入也像EXCEL一样有记忆功能。我在网上找了一段代码。无法实现,请老师帮修改。提示

花落,相依  发表于:2013-11-28 19:19:56  
复制

记忆录入

Option Compare Database

'原这句代码为为:(但提示为红色错误)
Private Sub ComboBox1_KeyUp(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
        AutoCompleteKeyUp(ComboBox1, e)
End Sub
'我改成绿色的也也提示错误
Private Sub ComboBox1_KeyUp(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.KeyEventArgs)
        Handles ComboBox1.KeyUp = AutoCompleteKeyUp(ComboBox1, e)
    End Sub

    Public Sub AutoCompleteKeyUp(ByVal Combo As ComboBox, ByVal e As KeyEventArgs)
        Dim strTyped As String
        Dim intFoundIndex As Integer
        Dim objFoundItem As Object
        Dim strFoundText As String
        Dim strAppendText As String
        '忽略这些基本操作键
        Select Case e.KeyCode
            Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, _
                Keys.Delete, Keys.Down, Keys.CapsLock
                Return
        End Select
        '看看用户输入了些什么
        strTyped = Combo.Text
        intFoundIndex = Combo.FindString(strTyped)
        '如果找到了的话……
        If intFoundIndex >= 0 Then
            '获取Combo下的匹配项
            objFoundItem = Combo.Items(intFoundIndex)
            '获取匹配的字符串
            strFoundText = Combo.GetItemText(objFoundItem)
            '开始自动添加文本
            strAppendText = strFoundText.Substring(strTyped.Length)
            Combo.Text = strTyped & strAppendText
            '选亮添加的文本
            Combo.SelectionStart = strTyped.Length
            Combo.SelectionLength = strAppendText.Length
        End If
    End Sub

 

 

 

Top
小赵 发表于:2013-11-28 22:50:15

窗体-属性里面-鼠标释放事件语句只有开头和结尾,没有中间执行语句。  请查看:
'Private Sub ComboBox1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)--这是开头
'中间是空的。
'End Sub--这是结束

所以出现些错误。建议把这段代码去掉。且你的‘表中-工程字段-写个名字’就可以了。



花落,相依 发表于:2013-11-29 07:01:59
请老师们帮修改一下

小赵 发表于:2013-11-29 22:14:05
不是都给出提示了吗?况且你的要求我没理解。

殷小宝 发表于:2013-11-29 23:34:28

鼠标释放与键释放事件中的参数是固定的,你改成别的参数了呢?我不知道你是从网上哪个地方找来的?



花落,相依 发表于:2013-11-30 06:23:43

是从这个网上找的。无法实现。http://blog.csdn.net/zou_seafarer/article/details/1531857



蒋元根 发表于:2013-12-01 06:21:55
新增记录时复制上一条记录的示例


http://www.accessoft.com/bbs/


总记录:6篇  页次:1/1 9 1 :