ACC2000: Combo Box Wizard Does Not Allow Selection of Table/Query

ID: Q208807


The information in this article applies to:

Moderate: Requires basic macro, coding, and interoperability skills.


SYMPTOMS

When you select the Find a record on my form based on the value I selected in my combo box option in the Combo Box Wizard dialog box, the Combo Box Wizard does not give you the option to select a table or query as your data source.


CAUSE

When you select the option to find a record based on your selection in the combo box, the Combo Box Wizard uses the data from the RecordSource property of the form as the RowSource property for the combo box.


RESOLUTION

To work around this behavior, let the Combo Box Wizard build the combo box, and then, after the Combo Box Wizard finishes building the combo box, manually change the RowSource property of the combo box to the table or query that you want. For an example of how to do so, follow the steps in the "Steps to Reproduce Behavior" section later in this article.


MORE INFORMATION

Steps to Reproduce Behavior

CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.

  1. Open the sample database Northwind.mdb.


  2. Create the following new query, add the Employees table, and save it as qryEmployeeList:


  3. 
       Query: qryEmployeeList
       -------------------------------------------
       Type: Select Query
    
       Field: EmployeeID
          Table: Employees
       Field: Name:[LastName] & ", " & [FirstName]
          Table: Employees
          Sort: Ascending 
  4. Open the Employees form in Design view.


  5. If it is not turned on, click the Control Wizards button in the toolbox (so that it appears pressed in) to turn on the Control Wizards.


  6. Click the Combo Box button in the toolbox, and add a combo box to the header section of the Employees form.


  7. Click the Find a record on my form based on the value I selected in my combo box option in Combo Box Wizard, and then click Next. Note that the Combo Box Wizard does not give you the option to select a table or query as the data source for the combo box. Instead, you are presented with a list of all fields available from the RecordSource property of the form.


  8. In the Control Wizard dialog box, move the EmployeeId and LastName fields from the Available Fields box to the Selected Fields Box, and then click Next. In the next window, Hide key column is checked, and the first column containing the EmployeeID is hidden. Click Next.


  9. In the What label would you like for your combo box? box, type Find Employee, and then click Finish.


  10. Open the form in Form view. Note that you can find employees by making selections from the combo box. To use the qryEmployeeList query that you created in step 2 above, you must change the form's RowSource property.


  11. Open the Employees form in Design view.


  12. Using the right mouse button, click the combo box that you added to the Employees form header section, and then click Properties on the menu that appears.


  13. Set the following properties for the combo box:


  14. 
       RowSourceType: Table/Query
       RowSource: qryEmployeeList
       ColumnCount: 2
       ColumnWidths: 0";2"
       BoundColumn: 1 
  15. Open the form in Form view. The Find Employees combo box now displays the employees' last names and first names in alphabetical order. Through customizing the combo box, the Combo Box Wizard has added the following code to AfterUpdate property of the combo box:
    
    Sub Combo43_AfterUpdate()
       'Find the record that matches the control.
       Me.RecordsetCone.FindFirst "[EmployeeID] = " & Me![Combo43]
       Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub 
    NOTE: Your Combo box control may have a name other than Combo43. To further synchronize the form and combo box so that the combo box always displays the name of the employee on the current record when you scroll through the records, add the following code to the form's OnCurrent property event procedure:
    
    Private Sub Form_Current()
       Me![Combo43] = Me![EmployeeID]
    End Sub 
    where [Combo43] is the name of your combo box.


  16. Open the form in Form view. Note that the combo box now displays the name of the employee on the current record. You can still use the combo box to find a specific employee.


REFERENCES

For more information about combo boxes, click Microsoft Access Help on the Help menu, type "Combo boxes: What they are and how they work." in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: prb


Keywords          : kbdta FmsCmbob 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 13, 1999