Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Combo Box question (Access 2003)

    I have a combo box that has values from a table in it. The fields in the table are Name, Emp#, and Activity. The combo box has the Activity in it. When the database loads, the user enters a login name. I want the value in the combo box to be the persons corresponding activity in the table, but they can change the value in the box if they prefer. Any help is appreciated.
    Nick

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Box question (Access 2003)

    Is the combo box on the same form where the user enters the login name?

  3. #3
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box question (Access 2003)

    It is on another form. A login form pops up and the user enters their name and selects ok. Another form loads with the combo box. their name is placed at the top of this form and i want the combo box to have the value of the activity that corresponds with the entered name.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Box question (Access 2003)

    Put the following code in the On Load event of the form with the combo box:

    Private Sub Form_Load()
    Me.cboActivity = DLookup("Activity", "tblSomething", "[Name] = " & Chr(34) & Forms!frmLogin!txtName & Chr(34))
    End Sub

    where:
    - cboActivity is the name of the combo box
    - tblSomething is the name of the table
    - frmLogin is the name of the login form.
    - txtName is the name of the text box on the login form where the user enters the login name.

  5. #5
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box question (Access 2003)

    Here is my code

    Me.cmbActCode = DLookup("activity", "tblEmployee", "Name = " & Chr(34) & [Forms]![frmlogin]![cmbEmpName].Column(0) & Chr(34))
    The name is coming froma combo box on the frmLogin. The code blows up when i run it. It just shows up a blank form.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Box question (Access 2003)

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  7. #7
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box question (Access 2003)

    The database is pretty large. I will try to size it down. Let me try to clarify my problem.

    I have a frmLogin where the user selects their name from a combo box and the selects an OK button.
    A new form comes up where the user can input misc data in textboxes, and one of the input items is a combo box that is the particular users activity performed. This activity is stored in a table with the users name. I want the default value in the combo box to be the activity associated with the selected name on the login screen, However I want the user to be able to select a different value in this activity combo box.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Box question (Access 2003)

    The problem is clear. I'll wait for the stripped down copy of the database.

  9. #9
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box question (Access 2003)

    Here is a versioin of the database.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combo Box question (Access 2003)

    Thanks. The easiest solution is to add the activity code to the Row Source combo box on frmLogin (modify the Row Source, increase the Column Count to 5 and add an extra column width of 0). The On Load code for frmMain then becomes

    Private Sub Form_Load()
    Me.cmbActCode = Forms!frmLogin!cmbEmpName.Column(4)
    End Sub

    In the attached version I had to create a table to act as Record Source for frmMain, you had removed it.

  11. #11
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Combo Box question (Access 2003)

    Thanks HansV, that worked perfect.
    Thanks again,
    Nick

Posting Permissions

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