设置Combobox.listindex [英] Setting Combobox.listindex

查看:421
本文介绍了设置Combobox.listindex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了我在互联网上可以找到的所有内容,但它没有帮助!我正在使用Windows XP和Access 2003.以下代码确实按照需要增加了listindex,但是在从Private Sub Combo返回之后,AfterUpdate()将其归零。您需要第一行来停止7777错误。另外,第三行激活Private Sub Combo AfterUpdate(),这也很不错。


1. On Error Resume Next

2. Me.Combo。 Setfocus

3. Me.Combo.Listindex = Me.Combo.Listindex +1


如果您使用F8手动执行代码,代码可以完美运行!然后当你运行代码w / o手动踩它时它不起作用。相反,它首先递增组合框,运行thu AfterUpdate()然后将其设置为零。我把这个.mdb变成了一个.mde,只是为了看看是否会让问题摆脱,但事实并非如此。请帮忙!!!谢谢,Ken。

I have read everything I can find on the internet, BUT it doesn''t help! I''m using Windows XP and Access 2003. The following code does increment the listindex as wanted but then after coming back from Private Sub Combo AfterUpdate() zeros it out. You need line one to stop the 7777 error. In addition, line three fires the Private Sub Combo AfterUpdate() which is nice too.

1. On Error Resume Next
2. Me.Combo.Setfocus
3. Me.Combo.Listindex = Me.Combo.Listindex +1

If you step thu the code manually with F8, the code works perfectly! Then when you run the code w/o stepping thu it manually it doesnt work. Instead it first increments the combo box, runs thu AfterUpdate() and then sets it to zero. I turned this .mdb into a .mde, just to see if that would shake the problem away, but it doesn''t. Please help!!! Thank, Ken.

推荐答案

请完整地发布您的代码,以及它应该完成的详细解释。
Please post your code in its entirety, along with a detailed explanation of what it is supposed to accomplish.


我想,你要做的是在组合框中向下移动一个项目。 On Error Resume Next 并没有停止你的错误7777 ,它只是忽略它,这是你的问题,我想,虽然你的陈述是关于它的归零出"并不是真的很重要。当你到达组合框中的最后一个项目,然后尝试移动到下一个不存在的项目时,会出现错误7777 !在运行这种代码之前,您需要检查以确保您不在最后一项;如果你是,你不会运行代码。

What you''re trying to do, I assume, is to move down one item in a combobox. The On Error Resume Next doesn''t stop your Error 7777, it just ignores it, which is your problem, I think, although your statement about it "zeroing it out" doesn''t really mean much. The Error 7777 occurs when you get to the last item in the combobox and then try to move to the next item, which doesn''t exist! Before running this kind of code you need to check to make sure that you aren''t already on the last item; if you are, you don''t run the code.

展开 | 选择 < span class =codeDivider> | Wrap | 行号


下面是代码:

Heres the code:

展开 < span class =codeDivider> | 选择 | Wrap | 行号


这篇关于设置Combobox.listindex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆