标题: Speeding Up Combo Boxes on Forms and the loading of Forms that contain Combo [打印本页] 作者: tmtony 时间: 2005-8-17 18:48 标题: Speeding Up Combo Boxes on Forms and the loading of Forms that contain Combo 标题:Speeding Up Combo Boxes on Forms and the loading of Forms that contain Combo Boxes. .
Combo Boxes are one of the easiest way to allow the user to pick from a category of input options or to pick a specific record. However, if the combo box is filed with data such as a list of customers, products or orders, or any other data which can run into the thousands of records, or is based on a complex query, this can dramatically slow down both the time it takes to open the combo box itself, and the time it takes to open and load the Form which contains the combo box.
Form loading time can become a problem because Access runs the query and sorts the records to fill the combo box at least twice just when opening the form. If you have multiple combo boxes on your form, this can make the form seem sluggish. Here's some hints to speed up the process of form loading and opening of combo boxes with large number of records:
1. It may sound self evident but make sure that the sort and parameter fields in the underlying query are indexed fields in the tables used.
2. Limit the number of fields returned to the combo box in the underling query.
3. Leave the Row Source for the combo box blank in its properties sheet. Then add an event procedure to the "On Enter" event of the combo box. In that procedure set the combo box's row source, to the desired query or table by specifying: Me!ComboBoxName.RowSource = "queryortablename"
This will make the form load faster by not running the combo box query until the user requests the data. (The combo box query is usually run again when the user selects it anyway.)
4. Set the "Auto Expand" property to No.
5. Limit the number of rows the combo box returns. Displaying 50 records is much faster than filling a combo box with 1000 or more records. There are many strategies to accomplish limiting the number of records that a combo box is filled with when it loads. One option is to make the combo box query dependent on, or filtered according to criteria of a text field on the same form. This is easy to do if you are using an alphabetical list such as a list of Customers.
Place a condition in the criteria field of the query which fills the combo which looks at another text control on the form for the first (and subsequent letters entered into the text box) such as: Like [Form]![txtAlpha] & "*" (Note you don't need the formal form name in the criteria, Access will look to the current form for the field,) then in the OnChange event of the field txtAlpha enter code in an event procedure similar to "MyCombo.Requery". Another advantage to this technique is that since the query returns no rows when the form is opened, the form loads faster as well.
6. If the Bound Column of the Combo Box is a numeric column of the query, don't hide this column. (Access 2) 作者: 爱情插班生 时间: 2005-8-19 00:10
标题:优化窗体组合框和加载含有组合框的窗体的速度
作者: 海狸先生 时间: 2005-8-20 00:38
5、限制组合框返回行数,在组合框中显示50条记录远比显示1000条或更多记录要快。这里一种选择是将组合框行来源设为一个查询,(注:查询中可以用同一窗体上某文本字段为筛选依据)。如果你要使用同类的列表,例如一个顾客列表,这将是非常容易的。 (我也是猜得很累,你参考一下吧)作者: chajiangliang 时间: 2005-8-26 04:19
5.限制組合框中的行數。顯示50條記錄的速度一定比1000條的速度快好多﹐有很多方法可以在加載組合框時限制其行數. 一是設定組合框的Rowsource為查詢, 其查詢中的條件來自于窗體上的文本框。如果你的窗體上要使用有一個以字母排序的客戶清單, 那么就很容易操作。在組合框(mycombo)中Rowsource那個的查詢的設計模式的條件欄中寫入窗體上那個起限制作用的文本框﹐如ike [Form]![txtAlpha] & "*",(無需寫Forms, 因為Access會在當前窗體上找此控件的)﹐再在txtAlpha的onchange事件下使用mycombo.requery即可。此方法的另外一個優點是在窗體在加載是組合框的返回記錄是0﹐所以打開窗體一樣很快。In my opnion﹕1. not in the OnChange Event to requery, but in the AfterUpdate. 2. We'd better pass SQL sentence to Combobox.rowsource in the OnLoad Event of the Form, then no query time needed before the form opens.作者: duanpeng@ 时间: 2005-8-29 10:31
有意思,谢!作者: txdsdn 时间: 2006-10-12 22:03
fghfghhgfh