Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35

    Open form from combo box

    I'm new to access and trying to make a combo box that gets it's data from a category table (Form 1, Form 2, Form 3). When the user selects Form 1 frm1 opens - Form 2 frm2 opens - Form 3 frm3 opens. The combo box is populated with the table info but not sure how to open the corresponding form when clicked on. This seems like it should be a simple task but I have spent hours trying to figure it out and cant. Thank you in advance.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You would use the AfterUpdate event of the ComboBox to open the form.

  3. #3
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Thanks but can you be more specific as I said I'm new to access.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use the Command Button wizard to create a button that opens a form. Then move the code in the Click event to the cbo and change it to use the cbo instead.

  5. #5
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Ok...I made 3 buttons with the Command Button wizzard that each open one of the 3 forms with a macro...not sure how i should move it to the Click event on the cbo???

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    My Internet is going up and down right now so pardon me if I don;t get back right away.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do you know how to convert the macros to code?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  9. #9
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Thanks...no i didn't ... i converted and have the codes for each button...now what do i do with each code?

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Instead of the Form name in the Command, put Me.ComboBoxName. (using YOUR ComboBox Name of course) If your cbo is bound to the column that contains the Form you want then it should open THAT form.

  11. #11
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If the combo box has the name of the forms in the bound column, your code might look like:

    Code:
    Private Sub YourComboBoxName_AfterUpdate()
    'change YourComboBoxName to the actual combo box name
    
       DoCmd.OpenForm Me.YourComboBoxName
    
    End Sub

  12. #12
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    Ok...now i'm lost again... I have code that looks like this:


    Private Sub cmdForm1_Click ()
    DoCmd.OpenForm "frm1", acNormal, "", "", , acNormal
    End Sub

    ... and one for Form 2 and Form 3
    Combo Box Name is cboForms

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Steve showed you the code that would go in the AfterUpdate event of the ComboBox.

  14. #14
    aceoftrades is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    35
    I switched to AfterUpdate and I kept getting a run-time error "The form name "2" is misspelled or refers to a form that doesn't exist." The "2" refers to the FormID so I renamed the forms from frm1, frm2, frm3 to 1, 2, 3, and it worked. I would rather not rename them so is there a way to have it look at a field FormName rather than FormID which is the PrimaryKey and autonumbered and open the form based on that instead?

  15. #15
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by aceoftrades View Post
    I switched to AfterUpdate and I kept getting a run-time error "The form name "2" is misspelled or refers to a form that doesn't exist." The "2" refers to the FormID so I renamed the forms from frm1, frm2, frm3 to 1, 2, 3, and it worked. I would rather not rename them so is there a way to have it look at a field FormName rather than FormID which is the PrimaryKey and autonumbered and open the form based on that instead?
    The row source for the combo box should be a query.

    The query would look like "SELECT FormName FROM TableName ORDER BY FormName" (change "TableName" to your table name- without quotes.)


    That is all you need.

    Or you could use:

    DoCmd.OpenForm Me.YourComboBoxName.Column(1)

    (column count is zero based)
    Last edited by ssanfu; 03-04-2012 at 03:48 PM. Reason: hit the wrong button

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. A Combo box that open another form
    By mar_t in forum Access
    Replies: 14
    Last Post: 01-09-2011, 10:53 PM
  2. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  3. Can you set a combo box to open links?
    By Procom Webserve in forum Access
    Replies: 2
    Last Post: 12-07-2009, 03:11 AM
  4. Open a form using a query that references a combo
    By accessbobp646 in forum Access
    Replies: 1
    Last Post: 02-22-2009, 09:50 AM
  5. Using combo box to open another form
    By ladyairj23 in forum Forms
    Replies: 0
    Last Post: 06-02-2006, 07:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums