Hi, I have this tables structures: Table Equipment equip_id name Table Customer customer_id Table Hire customer_id equip_id I want to create a form that uses a combo box to pick a customer name from, and a control (table maybe?) that will list all the equipments that the customer hired. I have to weigh the time spend to rebuild the form vs. Changing the combo box to a text box. Unfortunately, I could have used this method several times in the application. But not if its going to act this squirrelly. Looks at the different types of item counts you can get for listboxes and combo boxes. Access Archon #132 Introduction Recently I received some emails from AW readers requesting help on counting selections in listboxes and combo boxes. This article deals with the different types of item counts you can get for listboxes and combo boxes. In the case of listboxes, the question was how to determine the number of items currently selected in a listbox, and for a combo box, the question was how to get a count of all the times a specific item had been selected in a combo box. Listbox Counts Access listboxes have a very useful collection, SelectedItems, that contains the items currently selected in a multiselect listbox. This collection has a Count property that gives the number of selected items. I made a sample form, frmListboxCount, with a multiselect listbox with a row source of the Northwind Categories table (renamed tblCategories). The form also has a command button whose Click event procedure calculates the number of items selected in the listbox, and an unbound textbox to display the value. It brings numerous benefits no other backup solution will provide you with. Disk Drill stands apart from all the other backup tools. The form is shown in Figure A. A listbox with a command button to show the number of items selected VBA Codede Private Sub cmdCountSelectedItems_Click() On Error GoTo ErrorHandler Dim lngCount As Long Dim lst As Access.ListBox Set lst = Me![lstSelect] lngCount = Nz(lst.ItemsSelected.Count) Me![txtCount].Value = lngCount ErrorHandlerExit: Exit Sub ErrorHandler: MsgBox “Error No: ” & Err.Number & “; Description: ” & Err.Description Resume ErrorHandlerExit End Sub Combo Box Count Combo boxes have no ItemsSelected collection, since you can only select one item at a time in a combo box. However, you might want to record the number of times a particular item had been selected in a combo box, so I wrote code on the AfterUpdate event of a combo box on the frmComboBoxCount form to create new records in a table, tblCategorySelectionCount. I then made a totals query based on that table to give the totals by Category and Date, and display them in a datasheet subform. Xp-310 driver for mac. The form is shown in Figure B. A combo box with a subform displaying the number of times each item was selected The row source of the combo box is a union query, with a blank item that shows at the top of the list (to avoid confusion when opening the form – if not for the blank selection, it would look as if the Beverages item was selected). The union query’s SQL statement is listed below: SELECT tblCategories.CategoryID, tblCategories.CategoryName FROM tblCategories UNION SELECT 0 AS CategoryID, “” AS CategoryName FROM tblCategories; The Selection Count subform has as its record source the totals query qtotCategorySelectionCount, shown in design view in Figure C. A totals query that calculates the number of items selected by Category and Date. Click on the image to see the full size version. VBA Code The combo box’s AfterUpdate procedure is listed below: Private Sub cboSelect_AfterUpdate(). To create forms in Office Word 2008, you use the Forms toolbar. This toolbar contains options for making three basic types of forms: text forms, check-box forms and drop-down forms. If you're creating a form that requires a typed answer -- for example, one that asks for a name and has a field to fill in -- use a text form. If your form requires choosing among multiple options, choose a check-box form. The drop-down form features a menu that pulls down to reveal its list of options. You can also incorporate all three form types into one long document.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |