Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2012
    Posts
    126

    Unanswered: Combo Box Question

    I want to make a combo box control data on a form. Seems simple enough.

    I was able to accomplish this by creating two tables. One with EmployeeID and EmployeeName. The employee name is a look up field.

    I created a form with said table and it gives me employeeID and a drop down for EmployeeName. I dragged in a qry called employeeSales. The wizard asked me how I want to view my data and after selecting a few options my combo box declares which employee sales I see on the screen.

    My question:

    I'm wondering if there is another way to do this. Can I take my query EmployeeSales click the multi field form button. Then insert a combo box? I tried this and used employeeID from the EmployeeSales query and it lists the employees more than once and when i select one it goes to that record. This is not what Im looking for. I then tried to create the sql statement on my own and it doesn't control anything at this point. Im not sure what other angle to tackle this by.

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Why in the world do you need two tables for employeeid and employee name? They should be two fields in the same table.

    Sam

  3. #3
    Join Date
    Aug 2012
    Posts
    126
    Actually I was mistaken here. I created a second for testing purposes and thought I was pulling from it but im not.

    I know I can create a combo box with the list of names but without a subform how do I have it control fields from the employee table on a form. So select employee A and his address and etc comes up.

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    There are more ways to do that than I can think of, probably. I suggest you consult the help file (About Combo Boxes) and take your pick.

    Sam

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    First off, create a Table with EmployeeID, EmployeeName and other data only relevant to a given employee. Do not include a 'dropdown' Field at the Table-level; you can easily do that at the Form-level! To learn why, have a look here:

    The Evils of Lookup Fields in Tables

    As Sam suggested, have a look at the Help files on Comboboxes, or search here on them, but here's a very short tutorial on using one for this purpose:

    Set up your Combobox using the Wizard and include the Fields you need, from Left-to-Right.

    If in the Combobox they appear as

    Field1 | Field2 | Field3

    the code to assign the various bits of data would be

    Code:
    Private Sub YourComboBox_AfterUpdate()
       Me.txtField1 =  Me.YourComboBox.Column(0)
       Me.txtField2 = Me.YourComboBox.Column(1)
       Me.txtField3= Me.YourComboBox.Column(2)
    End Sub

    Notice that the column index is Zero-based, i.e. the first column is 0 (zero), the second is 1 and so forth.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Aug 2012
    Posts
    126
    Ling this pieced a lot together for me. Thank you ...as always!

    I used the help and the sample you gave and Im ready to tackle these the way I want

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Good luck with your project!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •